435 lines
15 KiB
PHP
435 lines
15 KiB
PHP
<?php
|
|
/**
|
|
* Geofeed Manager Login Page
|
|
*/
|
|
|
|
require_once __DIR__ . '/config.php';
|
|
|
|
$error = '';
|
|
$success = '';
|
|
|
|
// Handle logout
|
|
if (isset($_GET['logout'])) {
|
|
logoutUser();
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
// Already authenticated? Redirect to main page
|
|
if (isAuthenticated()) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
// Handle login form submission
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$username = trim($_POST['username'] ?? '');
|
|
$password = $_POST['password'] ?? '';
|
|
|
|
// Validate CSRF
|
|
if (!validateCSRFToken($_POST['csrf_token'] ?? '')) {
|
|
$error = 'Invalid security token. Please try again.';
|
|
} elseif (empty($username) || empty($password)) {
|
|
$error = 'Please enter both username and password.';
|
|
} elseif (authenticateUser($username, $password)) {
|
|
header('Location: index.php');
|
|
exit;
|
|
} else {
|
|
$error = 'Invalid username or password.';
|
|
// Add small delay to prevent brute force
|
|
usleep(500000);
|
|
}
|
|
}
|
|
|
|
$csrfToken = generateCSRFToken();
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover, user-scalable=no">
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
<meta name="theme-color" content="#6B2D7B" media="(prefers-color-scheme: light)">
|
|
<meta name="theme-color" content="#1a1a2e" media="(prefers-color-scheme: dark)">
|
|
<title>Login | Geofeed Manager</title>
|
|
<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@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 258 258'%3E%3Cpath fill='%23474a4c' d='M241.13 56.2A26.53 26.53 0 11188.07 56.2a26.53 26.53 0 0153.06 0zm-5.34-.05a21.19 21.19 0 10-42.38 0 21.19 21.19 0 0042.38 0z'/%3E%3Cpath fill='%23a23f97' d='M21.42 37.38h55.28a.32.32 0 01.32.32v12.21a.46.46 0 00.8.3c13.2-14.73 32.09-17.47 50.68-12.7 35.19 9.03 47.69 43.89 45.07 77C170.91 148.16 150.93 173.81 115.1 175.14q-22.52.84-37.38-15.22a.65.65 0 00-1.13.47c.06 1.2.49 2.44.49 4.15q-.04 23.9.01 56.37a.42.41 0 01-.42.41H21.66a.88.88 0 01-.88-.88V38.01a.64.63 0 01.64-.63zM77.02 104.64c0 12.43 5.67 26.28 20.24 26.28s20.25-13.85 20.25-26.28-5.67-26.28-20.25-26.28-20.24 13.85-20.24 26.28z'/%3E%3Cpath fill='%23474a4c' d='M221.39 61.32l4.27 7.4a1.09 1.09 0 01-.94 1.63h-.86a3.6 3.59 74.9 01-3.11-1.8l-3.42-5.93a1.73 1.72 74.8 00-1.49-.86h-5.78a.65.65 0 00-.65.65v6.54a1.26 1.26 0 01-1.26 1.26h-1.66a1.51 1.5 0 01-1.51-1.5V43.2a.88.88 0 01.89-.88c4.16.09 11.28-.78 15.02 1.14 5.3 2.72 7.21 7.98 4.13 13.34-.92 1.58-2.43 2.35-3.53 3.56a.82.81 51.2 00-.1.96zm-11.98-14.77l.06 11.22a.61.61 0 00.61.61l5.18-.03a7.25 6.14-.3 006.22-6.17v-.16a7.25 6.14-.3 00-7.28-6.11l-5.18.03a.61.61 0 00-.61.61z'/%3E%3Ccircle fill='%2331b05e' cx='163.95' cy='201.82' r='28.07'/%3E%3C/svg%3E">
|
|
<style>
|
|
:root {
|
|
--purple-primary: #6B2D7B;
|
|
--purple-dark: #4A1F55;
|
|
--purple-light: #8B4D9B;
|
|
--purple-lighter: #F5EDF7;
|
|
--purple-gradient: linear-gradient(135deg, #6B2D7B 0%, #8B4D9B 100%);
|
|
|
|
--bg-primary: #f8f9fa;
|
|
--bg-secondary: #ffffff;
|
|
--bg-tertiary: #f1f3f4;
|
|
--text-primary: #1a1a2e;
|
|
--text-secondary: #6c757d;
|
|
--text-tertiary: #868e96;
|
|
--border: rgba(0, 0, 0, 0.08);
|
|
--border-strong: rgba(0, 0, 0, 0.12);
|
|
|
|
--shadow-sm: 0 1px 3px rgba(107, 45, 123, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
|
|
--shadow-md: 0 4px 12px rgba(107, 45, 123, 0.1), 0 2px 4px rgba(0, 0, 0, 0.04);
|
|
--shadow-lg: 0 10px 40px rgba(107, 45, 123, 0.15), 0 4px 12px rgba(0, 0, 0, 0.05);
|
|
--shadow-xl: 0 25px 50px -12px rgba(107, 45, 123, 0.2);
|
|
|
|
--radius-sm: 8px;
|
|
--radius-md: 12px;
|
|
--radius-lg: 16px;
|
|
--radius-xl: 20px;
|
|
|
|
--error: #dc3545;
|
|
--error-bg: rgba(220, 53, 69, 0.1);
|
|
--success: #28a745;
|
|
--success-bg: rgba(40, 167, 69, 0.1);
|
|
|
|
--transition: all 0.2s ease;
|
|
|
|
--safe-area-top: env(safe-area-inset-top);
|
|
--safe-area-bottom: env(safe-area-inset-bottom);
|
|
}
|
|
|
|
@media (prefers-color-scheme: dark) {
|
|
:root {
|
|
--purple-primary: #9B5FAB;
|
|
--purple-dark: #7B3F8B;
|
|
--purple-light: #BB7FCB;
|
|
--purple-lighter: rgba(155, 95, 171, 0.15);
|
|
--purple-gradient: linear-gradient(135deg, #4A1F55 0%, #6B2D7B 100%);
|
|
|
|
--bg-primary: #0d0d14;
|
|
--bg-secondary: #1a1a2e;
|
|
--bg-tertiary: #252542;
|
|
--text-primary: #f0f0f5;
|
|
--text-secondary: #a0a0b0;
|
|
--text-tertiary: #707080;
|
|
--border: rgba(255, 255, 255, 0.08);
|
|
--border-strong: rgba(255, 255, 255, 0.12);
|
|
|
|
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
|
|
--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
|
|
--shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
--shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
|
|
|
|
--error-bg: rgba(220, 53, 69, 0.2);
|
|
--success-bg: rgba(40, 167, 69, 0.2);
|
|
}
|
|
}
|
|
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
html {
|
|
-webkit-tap-highlight-color: transparent;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
background: var(--bg-primary);
|
|
color: var(--text-primary);
|
|
line-height: 1.5;
|
|
-webkit-font-smoothing: antialiased;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 24px;
|
|
padding-top: max(24px, var(--safe-area-top));
|
|
padding-bottom: max(24px, var(--safe-area-bottom));
|
|
}
|
|
|
|
.login-container {
|
|
width: 100%;
|
|
max-width: 420px;
|
|
}
|
|
|
|
.login-card {
|
|
background: var(--bg-secondary);
|
|
border-radius: var(--radius-xl);
|
|
box-shadow: var(--shadow-xl);
|
|
border: 1px solid var(--border);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.login-header {
|
|
background: var(--purple-gradient);
|
|
color: white;
|
|
padding: 40px 32px;
|
|
text-align: center;
|
|
}
|
|
|
|
.logo {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 14px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.logo-icon {
|
|
width: 56px;
|
|
height: 56px;
|
|
background: rgba(255, 255, 255, 0.2);
|
|
border-radius: var(--radius-lg);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
backdrop-filter: blur(10px);
|
|
-webkit-backdrop-filter: blur(10px);
|
|
}
|
|
|
|
.logo-icon svg {
|
|
width: 36px;
|
|
height: 36px;
|
|
}
|
|
|
|
.login-title {
|
|
font-size: 24px;
|
|
font-weight: 700;
|
|
letter-spacing: -0.02em;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.login-subtitle {
|
|
font-size: 14px;
|
|
opacity: 0.9;
|
|
}
|
|
|
|
.login-form {
|
|
padding: 32px;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 8px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.03em;
|
|
}
|
|
|
|
.form-input {
|
|
width: 100%;
|
|
padding: 14px 16px;
|
|
font-size: 16px;
|
|
font-family: inherit;
|
|
background: var(--bg-tertiary);
|
|
border: 2px solid var(--border);
|
|
border-radius: var(--radius-md);
|
|
color: var(--text-primary);
|
|
transition: var(--transition);
|
|
outline: none;
|
|
}
|
|
|
|
.form-input:focus {
|
|
border-color: var(--purple-primary);
|
|
box-shadow: 0 0 0 4px rgba(107, 45, 123, 0.1);
|
|
}
|
|
|
|
.form-input::placeholder {
|
|
color: var(--text-tertiary);
|
|
}
|
|
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 100%;
|
|
padding: 14px 24px;
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
border-radius: var(--radius-md);
|
|
border: none;
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
font-family: inherit;
|
|
-webkit-touch-callout: none;
|
|
-webkit-user-select: none;
|
|
user-select: none;
|
|
}
|
|
|
|
.btn:active {
|
|
transform: scale(0.98);
|
|
}
|
|
|
|
.btn-primary {
|
|
background: var(--purple-primary);
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background: var(--purple-dark);
|
|
transform: translateY(-1px);
|
|
box-shadow: var(--shadow-md);
|
|
}
|
|
|
|
.btn-primary:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
}
|
|
|
|
.alert {
|
|
padding: 14px 16px;
|
|
border-radius: var(--radius-md);
|
|
font-size: 14px;
|
|
margin-bottom: 20px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.alert-error {
|
|
background: var(--error-bg);
|
|
color: var(--error);
|
|
border: 1px solid rgba(220, 53, 69, 0.3);
|
|
}
|
|
|
|
.alert-success {
|
|
background: var(--success-bg);
|
|
color: var(--success);
|
|
border: 1px solid rgba(40, 167, 69, 0.3);
|
|
}
|
|
|
|
.alert-icon {
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.login-footer {
|
|
text-align: center;
|
|
padding: 20px 32px 32px;
|
|
color: var(--text-tertiary);
|
|
font-size: 12px;
|
|
}
|
|
|
|
.login-footer a {
|
|
color: var(--purple-primary);
|
|
text-decoration: none;
|
|
}
|
|
|
|
.login-footer a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
/* Loading spinner */
|
|
.spinner {
|
|
display: none;
|
|
width: 18px;
|
|
height: 18px;
|
|
border: 2px solid rgba(255, 255, 255, 0.3);
|
|
border-radius: 50%;
|
|
border-top-color: white;
|
|
animation: spin 0.8s linear infinite;
|
|
margin-right: 8px;
|
|
}
|
|
|
|
.btn.loading .spinner {
|
|
display: inline-block;
|
|
}
|
|
|
|
.btn.loading .btn-text {
|
|
opacity: 0.7;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
/* Shake animation for errors */
|
|
@keyframes shake {
|
|
0%, 100% { transform: translateX(0); }
|
|
10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
|
|
20%, 40%, 60%, 80% { transform: translateX(5px); }
|
|
}
|
|
|
|
.shake {
|
|
animation: shake 0.5s ease-in-out;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-container">
|
|
<div class="login-card">
|
|
<div class="login-header">
|
|
<div class="logo">
|
|
<div class="logo-icon">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 258 258">
|
|
<path fill="white" d="M21.42 37.38h55.28a.32.32 0 01.32.32v12.21a.46.46 0 00.8.3c13.2-14.73 32.09-17.47 50.68-12.7 35.19 9.03 47.69 43.89 45.07 77C170.91 148.16 150.93 173.81 115.1 175.14q-22.52.84-37.38-15.22a.65.65 0 00-1.13.47c.06 1.2.49 2.44.49 4.15q-.04 23.9.01 56.37a.42.41 0 01-.42.41H21.66a.88.88 0 01-.88-.88V38.01a.64.63 0 01.64-.63zM77.02 104.64c0 12.43 5.67 26.28 20.24 26.28s20.25-13.85 20.25-26.28-5.67-26.28-20.25-26.28-20.24 13.85-20.24 26.28z"/>
|
|
<circle fill="rgba(255,255,255,0.6)" cx="200" cy="200" r="22"/>
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
<h1 class="login-title">Geofeed Manager</h1>
|
|
<p class="login-subtitle">Sign in to manage your geofeed entries</p>
|
|
</div>
|
|
|
|
<form class="login-form" method="POST" action="login.php" id="loginForm">
|
|
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($csrfToken) ?>">
|
|
|
|
<?php if ($error): ?>
|
|
<div class="alert alert-error shake">
|
|
<svg class="alert-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
<circle cx="12" cy="12" r="10"/>
|
|
<line x1="12" y1="8" x2="12" y2="12"/>
|
|
<line x1="12" y1="16" x2="12.01" y2="16"/>
|
|
</svg>
|
|
<span><?= htmlspecialchars($error) ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label" for="username">Username</label>
|
|
<input type="text" id="username" name="username" class="form-input" placeholder="Enter your username" required autocomplete="username" autofocus>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label" for="password">Password</label>
|
|
<input type="password" id="password" name="password" class="form-input" placeholder="Enter your password" required autocomplete="current-password">
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary" id="submitBtn">
|
|
<span class="spinner"></span>
|
|
<span class="btn-text">Sign In</span>
|
|
</button>
|
|
</form>
|
|
|
|
<div class="login-footer">
|
|
<p>Powered by <a href="https://purplecomputing.com" target="_blank" rel="noopener">Purple Computing</a></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Add loading state on form submit
|
|
document.getElementById('loginForm').addEventListener('submit', function(e) {
|
|
const btn = document.getElementById('submitBtn');
|
|
btn.classList.add('loading');
|
|
btn.disabled = true;
|
|
});
|
|
|
|
// Focus first empty field
|
|
const usernameField = document.getElementById('username');
|
|
const passwordField = document.getElementById('password');
|
|
if (usernameField.value) {
|
|
passwordField.focus();
|
|
} else {
|
|
usernameField.focus();
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|