Compare commits
No commits in common. "ai-dev" and "master" have entirely different histories.
7
auth.php
7
auth.php
@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
if (!isset($_SESSION['user_id'])) {
|
|
||||||
header('Location: login.php');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
86
contact.php
86
contact.php
@ -1,86 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once __DIR__ . '/mail/MailService.php';
|
|
||||||
|
|
||||||
$success_message = '';
|
|
||||||
$error_message = '';
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
||||||
$name = strip_tags(trim($_POST["name"]));
|
|
||||||
$email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
|
|
||||||
$message = trim($_POST["message"]);
|
|
||||||
|
|
||||||
if (empty($name) || empty($message) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
||||||
$error_message = "Por favor, preencha todos os campos corretamente.";
|
|
||||||
} else {
|
|
||||||
$to = getenv('MAIL_TO') ?: 'support@flatlogic.com'; // Fallback email
|
|
||||||
$subject = "Nova mensagem de contato de $name";
|
|
||||||
|
|
||||||
$res = MailService::sendContactMessage($name, $email, $message, $to, $subject);
|
|
||||||
|
|
||||||
if (!empty($res['success'])) {
|
|
||||||
$success_message = "Obrigado! A sua mensagem foi enviada com sucesso.";
|
|
||||||
} else {
|
|
||||||
$error_message = "Ocorreu um erro ao enviar a sua mensagem. Tente novamente mais tarde.";
|
|
||||||
// Optional: Log the detailed error: error_log($res['error']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="pt">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Contato - Gestão Imobiliária</title>
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
}
|
|
||||||
.contact-form {
|
|
||||||
max-width: 600px;
|
|
||||||
margin: 50px auto;
|
|
||||||
padding: 30px;
|
|
||||||
background-color: #ffffff;
|
|
||||||
border-radius: 8px;
|
|
||||||
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<div class="contact-form">
|
|
||||||
<h2 class="text-center mb-4">Entre em Contato</h2>
|
|
||||||
|
|
||||||
<?php if(!empty($success_message)): ?>
|
|
||||||
<div class="alert alert-success"><?php echo $success_message; ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if(!empty($error_message)): ?>
|
|
||||||
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<form action="contact.php" method="post">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="name" class="form-label">Nome</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="message" class="form-label">Mensagem</label>
|
|
||||||
<textarea class="form-control" id="message" name="message" rows="5" required></textarea>
|
|
||||||
</div>
|
|
||||||
<div class="d-grid">
|
|
||||||
<button type="submit" class="btn btn-primary">Enviar Mensagem</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<div class="text-center mt-3">
|
|
||||||
<a href="index.php">Voltar à página inicial</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once __DIR__ . '/config.php';
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Connect without specifying a database to create it first
|
|
||||||
$pdo_admin = new PDO('mysql:host=' . DB_HOST . ';charset=utf8mb4', DB_USER, DB_PASS, [
|
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
||||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
|
||||||
]);
|
|
||||||
$pdo_admin->exec("CREATE DATABASE IF NOT EXISTS `" . DB_NAME . "`;");
|
|
||||||
echo "Database '" . DB_NAME . "' created or already exists.\n";
|
|
||||||
|
|
||||||
// Now connect to the specific database to run migrations
|
|
||||||
$pdo = db();
|
|
||||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
||||||
|
|
||||||
$migrationsDir = __DIR__ . '/migrations';
|
|
||||||
$files = glob($migrationsDir . '/*.sql');
|
|
||||||
sort($files);
|
|
||||||
|
|
||||||
foreach ($files as $file) {
|
|
||||||
echo "Running migration: " . basename($file) . "\n";
|
|
||||||
$sql = file_get_contents($file);
|
|
||||||
$pdo->exec($sql);
|
|
||||||
echo "Success.\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "All migrations completed.\n";
|
|
||||||
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
die("Database migration failed: " . $e->getMessage());
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS users (
|
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
name VARCHAR(255) NOT NULL,
|
|
||||||
email VARCHAR(255) NOT NULL UNIQUE,
|
|
||||||
password VARCHAR(255) NOT NULL,
|
|
||||||
role ENUM('admin', 'client') NOT NULL DEFAULT 'client',
|
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
||||||
);
|
|
||||||
|
|
||||||
-- Add a default admin user for initial access
|
|
||||||
INSERT INTO users (name, email, password, role)
|
|
||||||
SELECT 'Admin', 'admin@example.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'admin' -- password is 'password'
|
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM users WHERE email = 'admin@example.com');
|
|
||||||
175
index.php
175
index.php
@ -1,67 +1,150 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once 'auth.php'; // Protects the page, requires login
|
declare(strict_types=1);
|
||||||
require_once 'db/config.php'; // For any potential DB access
|
@ini_set('display_errors', '1');
|
||||||
|
@error_reporting(E_ALL);
|
||||||
// User details are in the session
|
@date_default_timezone_set('UTC');
|
||||||
$userName = $_SESSION['user_name'] ?? 'User';
|
|
||||||
$userRole = $_SESSION['user_role'] ?? 'guest';
|
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
$phpVersion = PHP_VERSION;
|
||||||
$now = date('Y-m-d H:i:s');
|
$now = date('Y-m-d H:i:s');
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="pt">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>Dashboard - Gestão Imobiliária</title>
|
<title>New Style</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
<?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>
|
<style>
|
||||||
body {
|
:root {
|
||||||
background-color: #f8f9fa;
|
--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);
|
||||||
}
|
}
|
||||||
.navbar {
|
body {
|
||||||
margin-bottom: 2rem;
|
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>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
<main>
|
||||||
<div class="container">
|
|
||||||
<a class="navbar-brand" href="#">Gestão Imobiliária</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<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="#">Olá, <?php echo htmlspecialchars($userName); ?>!</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="logout.php">Logout</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="container">
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<h1>Analyzing your requirements and generating your website…</h1>
|
||||||
<h1 class="card-title">Bem-vindo ao seu Dashboard</h1>
|
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||||
<p class="card-text">Esta é a sua área privada. O seu perfil é: <strong><?php echo htmlspecialchars(ucfirst($userRole)); ?></strong>.</p>
|
<span class="sr-only">Loading…</span>
|
||||||
<p>A partir daqui, poderá gerir imóveis, clientes e visitas.</p>
|
</div>
|
||||||
<hr>
|
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||||
<p><a href="contact.php">Contactar Suporte</a></p>
|
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
<footer>
|
||||||
<footer class="text-center mt-4 text-muted">
|
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||||
<p>Page updated: <?= htmlspecialchars($now) ?> (UTC)</p>
|
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
88
login.php
88
login.php
@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
require_once 'db/config.php';
|
|
||||||
|
|
||||||
// If user is already logged in, redirect to home
|
|
||||||
if (isset($_SESSION['user_id'])) {
|
|
||||||
header('Location: index.php');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$error_message = '';
|
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
||||||
$email = $_POST['email'] ?? '';
|
|
||||||
$password = $_POST['password'] ?? '';
|
|
||||||
|
|
||||||
if (empty($email) || empty($password)) {
|
|
||||||
$error_message = 'Por favor, preencha o email e a senha.';
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
$pdo = db();
|
|
||||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
|
|
||||||
$stmt->execute([$email]);
|
|
||||||
$user = $stmt->fetch();
|
|
||||||
|
|
||||||
if ($user && password_verify($password, $user['password'])) {
|
|
||||||
// Password is correct, start session
|
|
||||||
$_SESSION['user_id'] = $user['id'];
|
|
||||||
$_SESSION['user_name'] = $user['name'];
|
|
||||||
$_SESSION['user_role'] = $user['role'];
|
|
||||||
header('Location: index.php');
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
$error_message = 'Email ou senha inválidos.';
|
|
||||||
}
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$error_message = 'Erro na base de dados. Por favor, tente novamente mais tarde.';
|
|
||||||
// For debugging, you might want to log the error
|
|
||||||
// error_log($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="pt">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Login - Gestão Imobiliária</title>
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 100vh;
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
}
|
|
||||||
.login-card {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 400px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="card login-card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h3 class="card-title text-center mb-4">Login</h3>
|
|
||||||
<?php if ($error_message): ?>
|
|
||||||
<div class="alert alert-danger"><?php echo htmlspecialchars($error_message); ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<form action="login.php" method="post">
|
|
||||||
<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">Senha</label>
|
|
||||||
<input type="password" class="form-control" id="password" name="password" required>
|
|
||||||
</div>
|
|
||||||
<div class="d-grid">
|
|
||||||
<button type="submit" class="btn btn-primary">Entrar</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
session_unset();
|
|
||||||
session_destroy();
|
|
||||||
header('Location: login.php');
|
|
||||||
exit;
|
|
||||||
Loading…
x
Reference in New Issue
Block a user