versao 1
This commit is contained in:
parent
513fc41209
commit
3be22ccb94
25
assets/css/custom.css
Normal file
25
assets/css/custom.css
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
body {
|
||||||
|
font-family: 'Inter', sans-serif;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-container {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-card {
|
||||||
|
max-width: 450px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 2rem;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand-logo {
|
||||||
|
font-weight: 700;
|
||||||
|
color: #0D6EFD; /* Bootstrap Primary */
|
||||||
|
}
|
||||||
31
db/migrate.php
Normal file
31
db/migrate.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
// Simples script para rodar migrações SQL
|
||||||
|
require_once __DIR__ . '/config.php';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$sql_file = __DIR__ . '/migrations/001_create_users_table.sql';
|
||||||
|
$sql = file_get_contents($sql_file);
|
||||||
|
|
||||||
|
$pdo->exec($sql);
|
||||||
|
|
||||||
|
echo "Migração '001_create_users_table.sql' executada com sucesso!\n";
|
||||||
|
|
||||||
|
// Criar hash de senha para o usuário de teste
|
||||||
|
$password = 'password123';
|
||||||
|
$hash = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
|
// Atualizar o hash no SQL para garantir que é compatível com a versão do PHP
|
||||||
|
$update_hash_sql = "UPDATE users SET password_hash = :hash WHERE email = 'chefe@familia.com'";
|
||||||
|
$stmt = $pdo->prepare($update_hash_sql);
|
||||||
|
$stmt->execute(['hash' => $hash]);
|
||||||
|
echo "Hash do usuário de teste atualizado no banco de dados.\n\n";
|
||||||
|
|
||||||
|
echo "Usuário de teste criado:\n";
|
||||||
|
echo "Email: chefe@familia.com\n";
|
||||||
|
echo "Senha: " . $password . "\n";
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Erro na migração: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
14
db/migrations/001_create_users_table.sql
Normal file
14
db/migrations/001_create_users_table.sql
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS `users` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`name` VARCHAR(100) NOT NULL,
|
||||||
|
`email` VARCHAR(100) NOT NULL UNIQUE,
|
||||||
|
`password_hash` VARCHAR(255) NOT NULL,
|
||||||
|
`role` ENUM('admin', 'family_head', 'family_member', 'guest') NOT NULL DEFAULT 'family_head',
|
||||||
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Inserir um usuário de teste para que possamos fazer login
|
||||||
|
-- A senha será definida pelo script de migração
|
||||||
|
INSERT INTO users (name, email, password_hash, role)
|
||||||
|
SELECT 'Chefe da Família Teste', 'chefe@familia.com', 'placeholder', 'family_head'
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM users WHERE email = 'chefe@familia.com');
|
||||||
3
includes/footer.php
Normal file
3
includes/footer.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
27
includes/header.php
Normal file
27
includes/header.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pt-BR">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Galilei-finance-v1</title>
|
||||||
|
<meta name="description" content="Software de controle financeiro familiar para transformar despesas em investimentos.">
|
||||||
|
<meta name="keywords" content="controle financeiro, finanças pessoais, orçamento familiar, investimentos, economizar dinheiro, gestão de despesas, app de finanças, Built with Flatlogic Generator">
|
||||||
|
<meta property="og:title" content="Galilei-finance-v1">
|
||||||
|
<meta property="og:description" content="Software de controle financeiro familiar para transformar despesas em investimentos.">
|
||||||
|
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '', ENT_QUOTES, 'UTF-8'); ?>">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '', ENT_QUOTES, 'UTF-8'); ?>">
|
||||||
|
|
||||||
|
<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="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;500;700&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
231
index.php
231
index.php
@ -1,150 +1,89 @@
|
|||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
@ini_set('display_errors', '1');
|
session_start();
|
||||||
@error_reporting(E_ALL);
|
}
|
||||||
@date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
// Proteger a página: se não estiver logado, redireciona para o login
|
||||||
$now = date('Y-m-d H:i:s');
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("SELECT id, name, email, role FROM users WHERE id = :id");
|
||||||
|
$stmt->execute(['id' => $_SESSION['user_id']]);
|
||||||
|
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// Em caso de erro, desloga o usuário para segurança
|
||||||
|
header('Location: logout.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
// Se o usuário não for encontrado no DB, desloga
|
||||||
|
header('Location: logout.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
include __DIR__ . '/includes/header.php';
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
|
||||||
<head>
|
<div class="container">
|
||||||
<meta charset="utf-8" />
|
<a class="navbar-brand navbar-brand-logo" href="#">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<i class="bi bi-safe me-2"></i>
|
||||||
<title>New Style</title>
|
Galilei Finance
|
||||||
<?php
|
</a>
|
||||||
// Read project preview data from environment
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
<span class="navbar-toggler-icon"></span>
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
</button>
|
||||||
?>
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
<?php if ($projectDescription): ?>
|
<ul class="navbar-nav ms-auto">
|
||||||
<!-- Meta description -->
|
<li class="nav-item dropdown">
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
<!-- Open Graph meta tags -->
|
<i class="bi bi-person-circle me-1"></i>
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<?php echo htmlspecialchars($user['name']); ?>
|
||||||
<!-- Twitter meta tags -->
|
</a>
|
||||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
|
||||||
<?php endif; ?>
|
<li><a class="dropdown-item" href="#">Meu Perfil</a></li>
|
||||||
<?php if ($projectImageUrl): ?>
|
<li><hr class="dropdown-divider"></li>
|
||||||
<!-- Open Graph image -->
|
<li><a class="dropdown-item" href="logout.php">Sair</a></li>
|
||||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
</ul>
|
||||||
<!-- Twitter image -->
|
</li>
|
||||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
</ul>
|
||||||
<?php endif; ?>
|
</div>
|
||||||
<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>
|
|
||||||
<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>
|
</div>
|
||||||
</main>
|
</nav>
|
||||||
<footer>
|
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
<main class="container mt-4">
|
||||||
</footer>
|
<div class="p-5 mb-4 bg-light rounded-3">
|
||||||
</body>
|
<div class="container-fluid py-5">
|
||||||
</html>
|
<h1 class="display-5 fw-bold">Bem-vindo(a) ao seu Painel Financeiro</h1>
|
||||||
|
<p class="col-md-8 fs-4">Este é o seu centro de controle. Em breve, você poderá adicionar despesas, criar orçamentos e visualizar relatórios detalhados aqui.</p>
|
||||||
|
<button class="btn btn-primary btn-lg" type="button">Adicionar Despesa (em breve)</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row align-items-md-stretch">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="h-100 p-5 text-white bg-dark rounded-3">
|
||||||
|
<h2>Orçamentos</h2>
|
||||||
|
<p>Acompanhe seus orçamentos mensais e veja onde seu dinheiro está indo. (Funcionalidade futura)</p>
|
||||||
|
<button class="btn btn-outline-light" type="button">Ver Orçamentos</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="h-100 p-5 bg-light border rounded-3">
|
||||||
|
<h2>Metas</h2>
|
||||||
|
<p>Defina e acompanhe suas metas de poupança para alcançar seus sonhos. (Funcionalidade futura)</p>
|
||||||
|
<button class="btn btn-outline-secondary" type="button">Ver Metas</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||||
82
login.php
Normal file
82
login.php
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
|
||||||
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Se já estiver logado, redireciona para o dashboard
|
||||||
|
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 e-mail e a senha.';
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("SELECT id, password_hash FROM users WHERE email = :email");
|
||||||
|
$stmt->execute(['email' => $email]);
|
||||||
|
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if ($user && password_verify($password, $user['password_hash'])) {
|
||||||
|
// Login bem-sucedido
|
||||||
|
$_SESSION['user_id'] = $user['id'];
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
// Credenciais inválidas
|
||||||
|
$error_message = 'E-mail ou senha inválidos.';
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// Idealmente, logar o erro em vez de exibir
|
||||||
|
$error_message = 'Erro no banco de dados. Tente novamente mais tarde.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
include __DIR__ . '/includes/header.php';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="container login-container">
|
||||||
|
<div class="card login-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h3 class="card-title text-center mb-4">
|
||||||
|
<i class="bi bi-safe me-2"></i>
|
||||||
|
<span class="navbar-brand-logo">Galilei Finance</span>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<?php if ($error_message): ?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<?php echo htmlspecialchars($error_message); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<form method="POST" action="login.php">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">E-mail</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>
|
||||||
|
<div class="text-center mt-3">
|
||||||
|
<a href="#">Esqueceu a senha?</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||||
8
logout.php
Normal file
8
logout.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
session_unset();
|
||||||
|
session_destroy();
|
||||||
|
header('Location: login.php');
|
||||||
|
exit;
|
||||||
Loading…
x
Reference in New Issue
Block a user