Compare commits

...

2 Commits

Author SHA1 Message Date
Flatlogic Bot
232ed5c114 V3 2025-12-01 09:10:54 +00:00
Flatlogic Bot
88faa8fb09 V1 2025-12-01 07:37:01 +00:00
25 changed files with 1004 additions and 158 deletions

5
.env Normal file
View File

@ -0,0 +1,5 @@
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=app
DB_USERNAME=root
DB_PASSWORD=password

22
README.md Normal file
View File

@ -0,0 +1,22 @@
# Agency Lead Generation Website
This project is a simple lead generation website for a medical agency. It includes a public-facing landing page with a contact form to capture leads.
## Project Structure
- `index.php`: The main landing page.
- `contact_handler.php`: Handles the contact form submission.
- `lib.php`: Contains helper functions.
- `assets/`: Contains CSS and JavaScript files.
- `css/custom.css`: Custom stylesheets.
- `js/main.js`: Custom JavaScript.
- `db/`: Contains database-related files.
- `config.php`: Database configuration and connection.
- `migrations/`: Contains database migration files.
- `.env`: Contains environment variables, including database credentials.
## Setup
1. Create a `.env` file and add your database credentials.
2. Run the migration scripts in `db/migrations/` to create the necessary tables.
3. (Optional) Run `db/seed.php` to seed the database with sample data.

47
admin/index.php Normal file
View File

@ -0,0 +1,47 @@
<?php
session_start();
require_once __DIR__ . '/../lib.php';
require_once __DIR__ . '/../db/config.php';
require_login();
$pdo = db();
$stmt = $pdo->query('SELECT * FROM leads');
$leads = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard</title>
</head>
<body>
<h1>Admin Dashboard</h1>
<p>Welcome to the admin dashboard.</p>
<p><a href="logout.php">Logout</a></p>
<h2>Leads</h2>
<table border="1">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
<?php foreach ($leads as $lead): ?>
<tr>
<td><?= htmlspecialchars($lead['id']) ?></td>
<td><?= htmlspecialchars($lead['name']) ?></td>
<td><?= htmlspecialchars($lead['email']) ?></td>
<td><?= htmlspecialchars($lead['created_at']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>

67
admin/login.php Normal file
View File

@ -0,0 +1,67 @@
<?php
session_start();
require_once __DIR__ . '/../lib.php';
require_once __DIR__ . '/../db/config.php';
if (is_logged_in()) {
header('Location: /admin/');
exit;
}
$error = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
if (login($username, $password)) {
header('Location: /admin/');
exit;
} else {
$error = 'Invalid username or password';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Login</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card mt-5">
<div class="card-header">
<h3 class="text-center">Admin Login</h3>
</div>
<div class="card-body">
<?php if ($error): ?>
<div class="alert alert-danger"><?= $error ?></div>
<?php endif; ?>
<form action="/admin/login.php" method="post">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</form>
<div class="text-center mt-3">
<p>Don't have an account? <a href="/registration.php">Register here</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

6
admin/logout.php Normal file
View File

@ -0,0 +1,6 @@
<?php
require_once __DIR__ . '/../lib.php';
logout();
header('Location: /admin/login.php');

3
assets/css/contact.css Normal file
View File

@ -0,0 +1,3 @@
.hero-section {
background-color: #f8f9fa;
}

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

@ -0,0 +1 @@
/* Custom CSS will go here */

3
assets/css/services.css Normal file
View File

@ -0,0 +1,3 @@
.hero-section {
background-color: #f8f9fa;
}

24
assets/js/contact.js Normal file
View File

@ -0,0 +1,24 @@
document.getElementById('contact-form').addEventListener('submit', function(event) {
event.preventDefault();
const form = event.target;
const formData = new FormData(form);
const formStatus = document.getElementById('form-status');
fetch('/contact_handler.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
form.reset();
formStatus.innerHTML = '<div class="alert alert-success">' + data.message + '</div>';
} else {
formStatus.innerHTML = '<div class="alert alert-danger">' + data.error + '</div>';
}
})
.catch(error => {
formStatus.innerHTML = '<div class="alert alert-danger">An error occurred. Please try again later.</div>';
});
});

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

@ -0,0 +1,62 @@
document.addEventListener('DOMContentLoaded', function () {
// Smooth scroll for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
const contactForm = document.getElementById('contactForm');
const formAlert = document.getElementById('form-alert');
if (contactForm) {
contactForm.addEventListener('submit', function (e) {
e.preventDefault();
e.stopPropagation();
if (!contactForm.checkValidity()) {
contactForm.classList.add('was-validated');
return;
}
const formData = new FormData(contactForm);
const submitButton = contactForm.querySelector('button[type="submit"]');
const originalButtonText = submitButton.innerHTML;
submitButton.disabled = true;
submitButton.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Sending...';
fetch('contact_handler.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
formAlert.classList.remove('d-none', 'alert-danger', 'alert-success');
if (data.success) {
formAlert.classList.add('alert-success');
formAlert.textContent = data.message;
contactForm.reset();
contactForm.classList.remove('was-validated');
} else {
formAlert.classList.add('alert-danger');
formAlert.textContent = data.error || 'An unknown error occurred.';
}
})
.catch(error => {
formAlert.classList.remove('d-none', 'alert-success');
formAlert.classList.add('alert-danger');
formAlert.textContent = 'A network error occurred. Please try again.';
console.error('Fetch Error:', error);
})
.finally(() => {
submitButton.disabled = false;
submitButton.innerHTML = originalButtonText;
});
});
}
});

78
contact.php Normal file
View File

@ -0,0 +1,78 @@
<?php
session_start();
require_once __DIR__ . '/lib.php';
require_once __DIR__ . '/db/config.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Us</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/contact.css">
</head>
<body>
<header class="bg-light p-3">
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" href="/">Your Logo</a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="/">Home</a></li>
<li class="nav-item"><a class="nav-link" href="/services.php">Services</a></li>
<li class="nav-item"><a class="nav-link" href="/contact.php">Contact</a></li>
</ul>
</div>
</nav>
</div>
</header>
<main>
<section class="hero-section text-center py-5">
<div class="container">
<h1 class="display-4">Contact Us</h1>
<p class="lead">We'd love to hear from you. Please fill out the form below.</p>
</div>
</section>
<section class="contact-form py-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<form id="contact-form">
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="phone" class="form-label">Phone (Optional)</label>
<input type="tel" class="form-control" id="phone" name="phone">
</div>
<div class="mb-3">
<label for="message" class="form-label">Message</label>
<textarea class="form-control" id="message" name="message" rows="5" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<div id="form-status" class="mt-3"></div>
</div>
</div>
</div>
</section>
</main>
<footer class="bg-light p-3 text-center">
<div class="container">
<p>&copy; 2025 Your Company. All Rights Reserved.</p>
</div>
</footer>
<script src="assets/js/contact.js"></script>
</body>
</html>

59
contact_handler.php Normal file
View File

@ -0,0 +1,59 @@
<?php
session_start();
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/mail/MailService.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode(['success' => false, 'error' => 'Method Not Allowed']);
exit;
}
$name = $_POST['name'] ?? '';
$email = $_POST['email'] ?? '';
$phone = $_POST['phone'] ?? '';
$message = $_POST['message'] ?? '';
if (empty($name) || empty($email) || empty($message)) {
http_response_code(400);
echo json_encode(['success' => false, 'error' => 'Please fill in all required fields.']);
exit;
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
http_response_code(400);
echo json_encode(['success' => false, 'error' => 'Invalid email format.']);
exit;
}
$pdo = db();
if (!$pdo) {
http_response_code(500);
echo json_encode(['success' => false, 'error' => 'Database connection failed.']);
exit;
}
try {
$stmt = $pdo->prepare("INSERT INTO leads (name, email, phone, message) VALUES (?, ?, ?, ?)");
$stmt->execute([$name, $email, $phone, $message]);
} catch (PDOException $e) {
http_response_code(500);
error_log('DB Insert Error: ' . $e->getMessage());
echo json_encode(['success' => false, 'error' => 'An error occurred while saving your message.']);
exit;
}
$contactEmailResult = MailService::sendContactMessage($name, $email, $message);
if (empty($contactEmailResult['success'])) {
// Log the error, but don't block the user. The lead is already saved.
error_log("Failed to send contact form email: " . ($contactEmailResult['error'] ?? 'Unknown error'));
}
if (!headers_sent()) {
header('Content-Type: application/json');
}
echo json_encode(['success' => true, 'message' => 'Thank you for your message! We will get back to you shortly.']);

41
dashboard.php Normal file
View File

@ -0,0 +1,41 @@
<?php
session_start();
if (!isset($_SESSION['user'])) {
header('Location: /login.php');
exit();
}
$user = $_SESSION['user'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">My App</a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="/logout.php">Logout</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1 class="mt-5">Welcome, <?php echo htmlspecialchars($user['username']); ?>!</h1>
<p>This is your dashboard.</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -1,17 +1,43 @@
<?php
// Generated by setup_mariadb_project.sh — edit as needed.
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'app_36525');
define('DB_USER', 'app_36525');
define('DB_PASS', '1a8cc708-b513-4573-a00c-73b5c345f14f');
function db() {
static $pdo;
if (!$pdo) {
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
}
return $pdo;
require_once __DIR__ . '/../lib.php';
$_ENV = array_merge($_ENV, load_env(__DIR__ . '/../.env'));
function db(): ?PDO
{
static $pdo = null;
if ($pdo !== null) {
return $pdo;
}
$host = $_ENV['DB_HOST'] ?? null;
$port = $_ENV['DB_PORT'] ?? null;
$db = $_ENV['DB_DATABASE'] ?? null;
$user = $_ENV['DB_USERNAME'] ?? null;
$pass = $_ENV['DB_PASSWORD'] ?? null;
if (!$host || !$db || !$user) {
// You could log an error or throw an exception here
return null;
}
$dsn = "mysql:host={$host};port={$port};dbname={$db};charset=utf8mb4";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$pdo = new PDO($dsn, $user, $pass, $options);
return $pdo;
} catch (PDOException $e) {
// In a real application, you'd log this error and show a generic error page.
// For development, it's okay to show the error.
error_log('DB Connection Error: ' . $e->getMessage());
return null;
}
}

22
db/migrate.php Normal file
View File

@ -0,0 +1,22 @@
<?php
require_once __DIR__ . '/config.php';
function run_migrations() {
$pdo = db();
$migrations_dir = __DIR__ . '/migrations';
$files = glob($migrations_dir . '/*.sql');
sort($files);
foreach ($files as $file) {
echo "Running migration: " . basename($file) . "\n";
$sql = file_get_contents($file);
try {
$pdo->exec($sql);
} catch (PDOException $e) {
echo "Error running migration: " . $e->getMessage() . "\n";
// You might want to log this or handle it more gracefully
}
}
}
run_migrations();

View File

@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS leads (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
phone VARCHAR(50),
message TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

View File

@ -0,0 +1,6 @@
CREATE TABLE IF NOT EXISTS `users` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(255) NOT NULL UNIQUE,
`password` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

View File

@ -0,0 +1 @@
ALTER TABLE users ADD COLUMN name VARCHAR(255) NOT NULL, ADD COLUMN email VARCHAR(255) NOT NULL UNIQUE;

24
db/seed.php Normal file
View File

@ -0,0 +1,24 @@
<?php
require_once __DIR__ . '/config.php';
function seed_users()
{
$pdo = db();
$username = 'admin';
$password = password_hash('password', PASSWORD_DEFAULT);
$stmt = $pdo->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
try {
$stmt->execute([$username, $password]);
echo "Admin user created successfully.\n";
} catch (PDOException $e) {
if ($e->errorInfo[1] == 1062) {
echo "Admin user already exists.\n";
} else {
echo "Error creating admin user: " . $e->getMessage() . "\n";
}
}
}
seed_users();

317
index.php
View File

@ -1,150 +1,179 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!doctype html>
<?php session_start(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<?php
// Read project preview data from environment
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<?php if ($projectDescription): ?>
<!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Medical Agency - Your Health is Our Priority</title>
<meta name="description" content="A leading medical agency providing top-tier health services, patient care, and treatment solutions.">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<style>
:root {
--bs-primary-rgb: 13, 110, 253; /* Custom primary color */
}
.hero-section {
background: linear-gradient(rgba(13, 110, 253, 0.05), rgba(255, 255, 255, 0)), url('https://images.pexels.com/photos/4021775/pexels-photo-4021775.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1') no-repeat center center;
background-size: cover;
color: #333;
}
.section-icon {
font-size: 2.5rem;
color: var(--bs-primary);
}
</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>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<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>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
<!-- Header -->
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm sticky-top">
<div class="container">
<a class="navbar-brand fw-bold" href="/">
<i class="bi bi-heart-pulse-fill text-primary"></i> MedAgency
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="/">Home</a></li>
<li class="nav-item"><a class="nav-link" href="/services.php">Services</a></li>
<li class="nav-item"><a class="nav-link" href="/contact.php">Contact</a></li>
<?php if (isset($_SESSION['user'])): ?>
<li class="nav-item"><a class="nav-link" href="/dashboard.php">Dashboard</a></li>
<li class="nav-item"><a class="btn btn-primary ms-lg-2" href="/logout.php">Logout</a></li>
<?php else: ?>
<li class="nav-item"><a class="nav-link" href="/registration.php">Register</a></li>
<li class="nav-item"><a class="btn btn-primary ms-lg-2" href="/login.php">Login</a></li>
<?php endif; ?>
</ul>
</div>
</div>
</nav>
<!-- Hero Section -->
<header class="hero-section py-5">
<div class="container text-center py-5">
<h1 class="display-4 fw-bold">Compassionate Care, Advanced Solutions</h1>
<p class="lead col-lg-8 mx-auto">We connect you with world-class medical experts and facilities, ensuring a seamless journey to better health.</p>
</div>
</header>
<main>
<!-- Services Section -->
<section id="services" class="py-5 bg-light">
<div class="container">
<div class="text-center mb-5">
<h2 class="fw-bold">Our Services</h2>
<p class="text-muted">Comprehensive support for your medical needs.</p>
</div>
<div class="row">
<!-- Service Item 1 -->
<div class="col-md-4 mb-4">
<div class="card h-100 text-center p-4">
<i class="bi bi-person-check-fill section-icon mb-3"></i>
<div class="card-body">
<h5 class="card-title fw-bold">Personalized Treatment Plans</h5>
<p class="card-text">Tailored medical strategies designed by top specialists to meet your unique health requirements.</p>
</div>
</div>
</div>
<!-- Service Item 2 -->
<div class="col-md-4 mb-4">
<div class="card h-100 text-center p-4">
<i class="bi bi-geo-alt-fill section-icon mb-3"></i>
<div class="card-body">
<h5 class="card-title fw-bold">International Client Services</h5>
<p class="card-text">Multi-language support and currency options for a hassle-free experience, no matter where you are.</p>
</div>
</div>
</div>
<!-- Service Item 3 -->
<div class="col-md-4 mb-4">
<div class="card h-100 text-center p-4">
<i class="bi bi-shield-check section-icon mb-3"></i>
<div class="card-body">
<h5 class="card-title fw-bold">Patient Workflow Management</h5>
<p class="card-text">A dedicated CRM to manage your entire treatment journey, from consultation to recovery.</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- About Section -->
<section id="about" class="py-5">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-6">
<img src="https://images.pexels.com/photos/5452292/pexels-photo-5452292.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1" class="img-fluid rounded shadow" alt="About MedAgency">
</div>
<div class="col-lg-6 mt-4 mt-lg-0">
<h2 class="fw-bold">About MedAgency</h2>
<p class="text-muted">Founded on the principle of patient-centric care, MedAgency was created to bridge the gap between patients and high-quality medical services worldwide. Our team is dedicated to providing transparent, efficient, and compassionate support throughout your healthcare journey.</p>
<p>We leverage cutting-edge technology and a vast network of certified professionals to ensure you receive the best possible care.</p>
</div>
</div>
</div>
</section>
<!-- Testimonials -->
<section id="testimonials" class="py-5 bg-light">
<div class="container">
<div class="text-center mb-5">
<h2 class="fw-bold">What Our Patients Say</h2>
</div>
<div class="row">
<div class="col-md-6 col-lg-4 mb-4">
<div class="card">
<div class="card-body">
<p class="fst-italic">"The entire process was so smooth and professional. MedAgency took care of everything, and I could focus solely on my recovery."</p>
<footer class="blockquote-footer mt-2">John Doe</footer>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4 mb-4">
<div class="card">
<div class="card-body">
<p class="fst-italic">"I was amazed by the level of personalized care. The team was always there to answer my questions and support me."</p>
<footer class="blockquote-footer mt-2">Jane Smith</footer>
</div>
</div>
</div>
<div class="col-md-12 col-lg-4 mb-4">
<div class="card">
<div class="card-body">
<p class="fst-italic">"Navigating international healthcare seemed daunting, but MedAgency made it simple and stress-free."</p>
<footer class="blockquote-footer mt-2">Samuel Lee</footer>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="bg-dark text-white py-4">
<div class="container text-center">
<p>&copy; <?php echo date("Y"); ?> MedAgency. All Rights Reserved.</p>
<div>
<a href="#" class="text-white me-2"><i class="bi bi-twitter"></i></a>
<a href="#" class="text-white me-2"><i class="bi bi-facebook"></i></a>
<a href="#" class="text-white"><i class="bi bi-linkedin"></i></a>
</div>
</div>
</footer>
<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>

77
lib.php Normal file
View File

@ -0,0 +1,77 @@
<?php
function load_env($path)
{
$vars = [];
if (!file_exists($path)) {
return $vars;
}
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
if (strpos(trim($line), '#') === 0) {
continue;
}
list($name, $value) = explode('=', $line, 2);
$name = trim($name);
$value = trim($value);
$vars[$name] = $value;
}
return $vars;
}
function login(string $username, string $password): bool
{
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
return true;
}
return false;
}
function logout(): void
{
$_SESSION = [];
session_destroy();
}
function is_logged_in(): bool
{
return isset($_SESSION['user_id']);
}
function require_login(): void
{
if (!is_logged_in()) {
header('Location: /admin/login.php');
exit;
}
}
function register(string $name, string $username, string $email, string $password): int|false
{
$pdo = db();
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$stmt = $pdo->prepare("INSERT INTO users (name, username, email, password) VALUES (?, ?, ?, ?)");
try {
$stmt->execute([$name, $username, $email, $hashed_password]);
return (int)$pdo->lastInsertId();
} catch (PDOException $e) {
// 1062 is the error code for duplicate entry
if ($e->errorInfo[1] == 1062) {
return false;
}
throw $e;
}
}

64
login.php Normal file
View File

@ -0,0 +1,64 @@
<?php
require_once 'lib.php';
session_start();
if (isset($_SESSION['user'])) {
header('Location: /dashboard.php');
exit();
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
if (login($username, $password)) {
header('Location: /dashboard.php');
exit();
} else {
$error = 'Invalid username or password';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card mt-5">
<div class="card-header">
<h4>User Login</h4>
</div>
<div class="card-body">
<?php if ($error): ?>
<div class="alert alert-danger"><?php echo $error; ?></div>
<?php endif; ?>
<form method="POST">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
<div class="mt-3">
<p>Don't have an account? <a href="registration.php">Register here</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

5
logout.php Normal file
View File

@ -0,0 +1,5 @@
<?php
session_start();
session_destroy();
header('Location: /login.php');
exit();

88
registration.php Normal file
View File

@ -0,0 +1,88 @@
<?php
session_start();
require_once __DIR__ . '/lib.php';
require_once __DIR__ . '/db/config.php';
if (is_logged_in()) {
header('Location: /admin/');
exit;
}
$error = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['name'] ?? '';
$username = $_POST['username'] ?? '';
$email = $_POST['email'] ?? '';
$password = $_POST['password'] ?? '';
$confirm_password = $_POST['confirm_password'] ?? '';
if ($password !== $confirm_password) {
$error = 'Passwords do not match';
} else {
$user_id = register($name, $username, $email, $password);
if ($user_id) {
$_SESSION['user_id'] = $user_id;
header('Location: /admin/');
exit;
} else {
$error = 'Username or email already exists';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Register</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card mt-5">
<div class="card-header">
<h3 class="text-center">Register</h3>
</div>
<div class="card-body">
<?php if ($error): ?>
<div class="alert alert-danger"><?= $error ?></div>
<?php endif; ?>
<form action="/registration.php" method="post">
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="mb-3">
<label for="confirm_password" class="form-label">Confirm Password</label>
<input type="password" class="form-control" id="confirm_password" name="confirm_password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">Register</button>
</div>
</form>
<div class="text-center mt-3">
<p>Already have an account? <a href="/admin/login.php">Login here</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

78
services.php Normal file
View File

@ -0,0 +1,78 @@
<?php
session_start();
require_once __DIR__ . '/lib.php';
require_once __DIR__ . '/db/config.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Services</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/services.css">
</head>
<body>
<header class="bg-light p-3">
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" href="/">Your Logo</a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="/">Home</a></li>
<li class="nav-item"><a class="nav-link" href="/services.php">Services</a></li>
<li class="nav-item"><a class="nav-link" href="/contact.php">Contact</a></li>
</ul>
</div>
</nav>
</div>
</header>
<main>
<section class="hero-section text-center py-5">
<div class="container">
<h1 class="display-4">Our Services</h1>
<p class="lead">We offer a wide range of services to meet your needs.</p>
</div>
</section>
<section class="services-list py-5">
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="card mb-4">
<div class="card-body">
<h5 class="card-title">Service 1</h5>
<p class="card-text">Description of service 1.</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4">
<div class="card-body">
<h5 class="card-title">Service 2</h5>
<p class="card-text">Description of service 2.</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4">
<div class="card-body">
<h5 class="card-title">Service 3</h5>
<p class="card-text">Description of service 3.</p>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
<footer class="bg-light p-3 text-center">
<div class="container">
<p>&copy; 2025 Your Company. All Rights Reserved.</p>
</div>
</footer>
</body>
</html>