diff --git a/README.md b/README.md index 4abc521..1d2af70 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,17 @@ e resetar senha, com controle de acesso gerenciado pela própria aplicação. - `sql/schema.sql` — schema do banco (admins, settings, audit_log, login_attempts). - `storage/` — log de auditoria em arquivo (complementar ao banco). +## URLs amigáveis + +O `public_html/.htaccess` esconde a extensão `.php` (requer `mod_rewrite` e +`AllowOverride FileInfo`/`Limit` no vhost, já presentes na config desse site): +`/dashboard`, `/admins`, `/auditoria`, `/settings`, `/logout` etc. em vez de +`dashboard.php`, `admins.php`... Acessar o `.php` direto redireciona pra URL limpa. + ## Papéis -- **admin**: tudo que operador pode, mais gerenciar `admins.php` e `settings.php`. -- **operador**: só habilita/desabilita aluno e reseta senha no `dashboard.php`. +- **admin**: tudo que operador pode, mais gerenciar administradores e configurações. +- **operador**: só habilita/desabilita aluno e reseta senha no dashboard. A autenticação de quem usa o sistema é sempre feita com login e senha do próprio AD (bind LDAP) — o banco **não armazena nenhuma senha**. A tabela `admins` só guarda diff --git a/public_html/.htaccess b/public_html/.htaccess new file mode 100644 index 0000000..2da6d70 --- /dev/null +++ b/public_html/.htaccess @@ -0,0 +1,27 @@ +RewriteEngine On +RewriteBase / + +# Esconde a extensão .php: se alguém acessar /dashboard.php direto, redireciona +# pra /dashboard (sem expor o nome do arquivo em links/histórico). +RewriteCond %{THE_REQUEST} \s/+([^.\s]+)\.php[\s?] [NC] +RewriteRule ^ /%1 [R=301,L] + +# Bloqueia acesso a qualquer coisa fora de public_html através de URL, +# mesmo sem rewrite (defesa extra, já que src/config/storage ficam um +# nível acima e não deveriam ser alcançáveis mesmo sem isso). +RewriteRule ^(src|config|storage|sql)(/|$) - [F,L] + +# Roteia /algumacoisa para algumacoisa.php quando o arquivo existir e +# nenhum arquivo/diretório real com esse nome exista. +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{DOCUMENT_ROOT}/$1.php -f +RewriteRule ^([a-zA-Z0-9_-]+)$ $1.php [L,QSA] + +# Nunca serve .htaccess/.env ou outro arquivo de config por engano. +# (Options -Indexes não entra aqui de propósito: o AllowOverride do vhost +# não libera o contexto "Options", só FileInfo/AuthConfig/Limit -- colocar +# a diretiva aqui derrubaria o site com "Options not allowed here".) + + Require all denied + diff --git a/public_html/action_status.php b/public_html/action_status.php index 20b400d..b0bb3fd 100644 --- a/public_html/action_status.php +++ b/public_html/action_status.php @@ -6,7 +6,7 @@ require __DIR__ . '/../src/bootstrap.php'; Auth::requireLogin(); if ($_SERVER['REQUEST_METHOD'] !== 'POST') { - header('Location: dashboard.php'); + header('Location: dashboard'); exit; } @@ -14,7 +14,7 @@ $user = trim((string) ($_POST['user'] ?? '')); $enable = ($_POST['enable'] ?? '') === '1'; if ($user === '') { - header('Location: dashboard.php?erro=1&msg=' . urlencode('Usuário inválido.')); + header('Location: dashboard?erro=1&msg=' . urlencode('Usuário inválido.')); exit; } @@ -39,9 +39,9 @@ try { AuditLog::record($quemFez, $enable ? 'habilitou_aluno' : 'desabilitou_aluno', $user); - header('Location: dashboard.php?ok=1'); + header('Location: dashboard?ok=1'); exit; } catch (Throwable $e) { - header('Location: dashboard.php?erro=1&msg=' . urlencode($e->getMessage())); + header('Location: dashboard?erro=1&msg=' . urlencode($e->getMessage())); exit; } diff --git a/public_html/admins.php b/public_html/admins.php index cd0df29..a0690a7 100644 --- a/public_html/admins.php +++ b/public_html/admins.php @@ -86,7 +86,7 @@ View::header('Administradores');
-
+ @@ -108,11 +108,11 @@ View::header('Administradores'); - - - + + + - + diff --git a/public_html/assets/style.css b/public_html/assets/style.css index 2bd367a..ffa2b2d 100644 --- a/public_html/assets/style.css +++ b/public_html/assets/style.css @@ -1,54 +1,157 @@ :root { color-scheme: light; - --bg: #f4f5f7; + --bg: #f1f3f8; + --bg-pattern: radial-gradient(circle at 10% -10%, #dbe4ff 0%, transparent 45%), + radial-gradient(circle at 110% 10%, #e3f3ff 0%, transparent 40%); --card: #ffffff; - --text: #1f2430; - --muted: #6b7280; - --border: #e2e4e9; - --accent: #2563eb; + --card-border: #e7e9f0; + --text: #1a1d29; + --text-muted: #6b7280; + --border: #e7e9f0; + --accent: #4f46e5; + --accent-2: #4338ca; + --accent-soft: #eef0ff; --accent-contrast: #ffffff; --danger: #dc2626; + --danger-soft: #fee2e2; --success: #16a34a; + --success-soft: #dcfce7; + --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06); + --shadow-md: 0 8px 24px -8px rgba(16, 24, 40, 0.18), 0 2px 6px rgba(16, 24, 40, 0.06); + --radius: 14px; + --radius-sm: 8px; +} + +@media (prefers-color-scheme: dark) { + :root:not([data-theme="light"]) { + color-scheme: dark; + --bg: #0f1117; + --bg-pattern: radial-gradient(circle at 10% -10%, #1e2140 0%, transparent 45%), + radial-gradient(circle at 110% 10%, #10233a 0%, transparent 40%); + --card: #171923; + --card-border: #272b3a; + --text: #eef0f5; + --text-muted: #9aa0b2; + --border: #272b3a; + --accent: #6d66f0; + --accent-2: #857ef5; + --accent-soft: #211f3d; + --accent-contrast: #ffffff; + --danger: #f87171; + --danger-soft: #3a1a1c; + --success: #4ade80; + --success-soft: #11301f; + --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3); + --shadow-md: 0 12px 32px -12px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35); + } +} + +:root[data-theme="dark"] { + color-scheme: dark; + --bg: #0f1117; + --bg-pattern: radial-gradient(circle at 10% -10%, #1e2140 0%, transparent 45%), + radial-gradient(circle at 110% 10%, #10233a 0%, transparent 40%); + --card: #171923; + --card-border: #272b3a; + --text: #eef0f5; + --text-muted: #9aa0b2; + --border: #272b3a; + --accent: #6d66f0; + --accent-2: #857ef5; + --accent-soft: #211f3d; + --accent-contrast: #ffffff; + --danger: #f87171; + --danger-soft: #3a1a1c; + --success: #4ade80; + --success-soft: #11301f; + --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3); + --shadow-md: 0 12px 32px -12px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35); } * { box-sizing: border-box; } +html { -webkit-text-size-adjust: 100%; } + body { margin: 0; - font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif; - background: var(--bg); + min-height: 100vh; + font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; + background-color: var(--bg); + background-image: var(--bg-pattern); + background-attachment: fixed; color: var(--text); + -webkit-font-smoothing: antialiased; } +/* Topbar */ + .topbar { display: flex; justify-content: space-between; align-items: center; + gap: 16px; padding: 14px 24px; - background: var(--card); + background: color-mix(in srgb, var(--card) 88%, transparent); + backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); + position: sticky; + top: 0; + z-index: 20; + flex-wrap: wrap; +} + +.topbar strong { + font-weight: 700; + letter-spacing: -0.01em; + font-size: 15px; + white-space: nowrap; +} + +.topbar nav { + display: flex; + align-items: center; + gap: 4px; + flex-wrap: wrap; +} + +.topbar nav span { + color: var(--text-muted); + font-size: 13px; + margin-right: 10px; + padding-right: 10px; + border-right: 1px solid var(--border); } .topbar nav a { - margin-left: 16px; - color: var(--text); + color: var(--text-muted); text-decoration: none; font-size: 14px; + font-weight: 500; + padding: 7px 12px; + border-radius: 999px; + transition: background-color 0.15s ease, color 0.15s ease; + white-space: nowrap; } -.topbar nav a:hover { color: var(--accent); } +.topbar nav a:hover { + color: var(--accent); + background: var(--accent-soft); +} + +/* Layout */ .container { - max-width: 960px; - margin: 32px auto; - padding: 0 16px; + max-width: 1000px; + margin: 0 auto; + padding: 28px 16px 48px; } .card { background: var(--card); - border: 1px solid var(--border); - border-radius: 10px; - padding: 24px; + border: 1px solid var(--card-border); + border-radius: var(--radius); + padding: 28px; + box-shadow: var(--shadow-sm); } .login-wrap { @@ -56,46 +159,210 @@ body { min-height: 100vh; align-items: center; justify-content: center; + padding: 16px; +} + +.login-wrap .card { + width: 100%; + max-width: 380px; + box-shadow: var(--shadow-md); + animation: rise 0.35s ease; } -.login-wrap .card { width: 100%; max-width: 360px; } +.login-wrap .card h1 { + text-align: center; + margin-bottom: 4px; +} -h1 { font-size: 20px; margin: 0 0 16px; } +.login-sub { + text-align: center; + color: var(--text-muted); + font-size: 13px; + margin: 0 0 22px; +} -label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; } +@keyframes rise { + from { opacity: 0; transform: translateY(8px); } + to { opacity: 1; transform: translateY(0); } +} -input[type=text], input[type=password], select { +h1 { + font-size: 21px; + font-weight: 700; + letter-spacing: -0.01em; + margin: 0 0 18px; +} + +label { + display: block; + font-size: 13px; + font-weight: 500; + color: var(--text-muted); + margin-bottom: 6px; +} + +input[type=text], +input[type=password], +select { width: 100%; - padding: 8px 10px; - margin-bottom: 14px; + padding: 10px 12px; + margin-bottom: 16px; border: 1px solid var(--border); - border-radius: 6px; + border-radius: var(--radius-sm); font-size: 14px; + background: var(--bg); + color: var(--text); + transition: border-color 0.15s ease, box-shadow 0.15s ease; +} + +input[type=text]:focus, +input[type=password]:focus, +select:focus { + outline: none; + border-color: var(--accent); + box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); } button, .btn { - display: inline-block; + display: inline-flex; + align-items: center; + justify-content: center; + gap: 6px; background: var(--accent); + background-image: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-contrast); border: none; - padding: 8px 14px; - border-radius: 6px; + padding: 9px 16px; + border-radius: var(--radius-sm); font-size: 14px; + font-weight: 600; cursor: pointer; text-decoration: none; + box-shadow: var(--shadow-sm); + transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease; +} + +button:hover, .btn:hover { opacity: 0.92; } +button:active, .btn:active { transform: translateY(1px); } + +button.danger, .btn.danger { + background-image: none; + background: var(--danger); +} + +button.secondary, .btn.secondary { + background-image: none; + background: transparent; + color: var(--text-muted); + border: 1px solid var(--border); + box-shadow: none; +} + +button.secondary:hover, .btn.secondary:hover { + color: var(--text); + border-color: var(--text-muted); + opacity: 1; +} + +/* Tabela / responsiva */ + +table { + width: 100%; + border-collapse: collapse; + margin-top: 16px; +} + +th, td { + text-align: left; + padding: 12px 10px; + border-bottom: 1px solid var(--border); + font-size: 14px; + vertical-align: middle; +} + +th { + color: var(--text-muted); + font-weight: 600; + font-size: 12px; + text-transform: uppercase; + letter-spacing: 0.03em; +} + +tr:last-child td { border-bottom: none; } + +.badge { + display: inline-block; + padding: 3px 10px; + border-radius: 999px; + font-size: 12px; + font-weight: 600; } -button.danger, .btn.danger { background: var(--danger); } -button.secondary, .btn.secondary { background: var(--muted); } +.badge.ok { background: var(--success-soft); color: var(--success); } +.badge.off { background: var(--danger-soft); color: var(--danger); } -table { width: 100%; border-collapse: collapse; margin-top: 12px; } -th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; } -th { color: var(--muted); font-weight: 600; } +.alert { + padding: 11px 16px; + border-radius: var(--radius-sm); + margin-bottom: 18px; + font-size: 14px; + border: 1px solid transparent; +} -.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; } -.badge.ok { background: #dcfce7; color: var(--success); } -.badge.off { background: #fee2e2; color: var(--danger); } +.alert.error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); } +.alert.success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); } -.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; } -.alert.error { background: #fee2e2; color: var(--danger); } -.alert.success { background: #dcfce7; color: var(--success); } +.hint { + color: var(--text-muted); + font-size: 13px; +} + +code { + background: var(--accent-soft); + color: var(--accent); + padding: 2px 6px; + border-radius: 4px; + font-size: 12.5px; +} + +/* Responsivo: tabela vira "cards" empilhados no celular */ + +@media (max-width: 720px) { + .container { padding: 20px 12px 40px; } + .card { padding: 18px; border-radius: 12px; } + + .topbar { padding: 12px 16px; } + .topbar nav span { border-right: none; padding-right: 0; margin-right: 0; width: 100%; order: -1; } + + table, thead, tbody, th, td, tr { display: block; } + thead { display: none; } + + tr { + border: 1px solid var(--border); + border-radius: var(--radius-sm); + margin-bottom: 12px; + padding: 10px 12px; + } + + td { + border-bottom: none; + padding: 6px 0; + display: flex; + justify-content: space-between; + align-items: center; + gap: 12px; + text-align: right; + } + + td::before { + content: attr(data-label); + font-size: 12px; + font-weight: 600; + color: var(--text-muted); + text-transform: uppercase; + letter-spacing: 0.03em; + text-align: left; + } + + td form { justify-content: flex-end; } +} diff --git a/public_html/auditoria.php b/public_html/auditoria.php index 90d6456..3993365 100644 --- a/public_html/auditoria.php +++ b/public_html/auditoria.php @@ -40,7 +40,7 @@ View::header('Auditoria'); ?>

Auditoria

-

+

Histórico de logins (inclusive tentativas com senha incorreta), alterações em alunos, administradores e configurações. Mostrando de registros.

@@ -56,12 +56,12 @@ View::header('Auditoria'); - - - - - - + + + + + + @@ -75,7 +75,7 @@ View::header('Auditoria'); - + | diff --git a/public_html/dashboard.php b/public_html/dashboard.php index de19de7..53c3545 100644 --- a/public_html/dashboard.php +++ b/public_html/dashboard.php @@ -61,24 +61,24 @@ View::header('Alunos'); - - + + Habilitado Desabilitado - - - + + + - Nova senha + Nova senha diff --git a/public_html/index.php b/public_html/index.php index af6c9b3..d92fcf7 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -5,7 +5,7 @@ declare(strict_types=1); require __DIR__ . '/../src/bootstrap.php'; if (!empty($_SESSION['login'])) { - header('Location: dashboard.php'); + header('Location: dashboard'); exit; } @@ -20,7 +20,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } else { $result = Auth::attempt($login, $senha); if ($result['ok']) { - header('Location: dashboard.php'); + header('Location: dashboard'); exit; } $erro = $result['error']; @@ -33,17 +33,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { + Gestão de Alunos Lab. Informática + + +
-- libgit2 0.21.2