![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/.cursor-server/data/User/History/-3bd2767a/ |
<?php
/**
* Login Page
* Migrated from React login component
*/
require_once 'config/config.php';
require_once 'auth/Auth.php';
$auth = new Auth();
$error = '';
$success = '';
// Redirect if already logged in
if ($auth->isLoggedIn()) {
header('Location: /dashboard.php');
exit;
}
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';
if (empty($email) || empty($password)) {
$error = 'Please fill in all fields';
} else {
$result = $auth->login($email, $password);
if ($result['success']) {
header('Location: /dashboard.php');
exit;
} else {
$error = $result['message'];
}
}
}
// Get language from URL parameter or default
$language = $_GET['lang'] ?? DEFAULT_LANGUAGE;
if (!in_array($language, SUPPORTED_LANGUAGES)) {
$language = DEFAULT_LANGUAGE;
}
// Bilingual content
$content = [
'fr' => [
'title' => 'Connexion - avocat.quebec',
'heading' => 'Connexion',
'subheading' => 'Accédez à votre compte avocat.quebec',
'email' => 'Adresse e-mail',
'password' => 'Mot de passe',
'login' => 'Se connecter',
'forgotPassword' => 'Mot de passe oublié ?',
'noAccount' => "Vous n'avez pas de compte ?",
'signUp' => 'Créer un compte',
'backToHome' => 'Retour à l\'accueil'
],
'en' => [
'title' => 'Login - avocat.quebec',
'heading' => 'Login',
'subheading' => 'Access your avocat.quebec account',
'email' => 'Email Address',
'password' => 'Password',
'login' => 'Sign In',
'forgotPassword' => 'Forgot Password?',
'noAccount' => "Don't have an account?",
'signUp' => 'Create Account',
'backToHome' => 'Back to Home'
]
];
$currentContent = $content[$language];
?>
<!DOCTYPE html>
<html lang="<?php echo $language; ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $currentContent['title']; ?></title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<style>
.gradient-bg {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
</style>
</head>
<body class="bg-gray-50 min-h-screen flex items-center justify-center">
<div class="max-w-md w-full space-y-8">
<!-- Header -->
<div class="text-center">
<a href="/" class="text-3xl font-bold text-blue-600">avocat.quebec</a>
<h2 class="mt-6 text-3xl font-extrabold text-gray-900">
<?php echo $currentContent['heading']; ?>
</h2>
<p class="mt-2 text-sm text-gray-600">
<?php echo $currentContent['subheading']; ?>
</p>
</div>
<!-- Login Form -->
<div class="bg-white py-8 px-6 shadow-lg rounded-lg">
<?php if ($error): ?>
<div class="mb-4 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
<?php echo htmlspecialchars($error); ?>
</div>
<?php endif; ?>
<?php if ($success): ?>
<div class="mb-4 bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
<?php echo htmlspecialchars($success); ?>
</div>
<?php endif; ?>
<form class="space-y-6" method="POST">
<div>
<label for="email" class="block text-sm font-medium text-gray-700">
<?php echo $currentContent['email']; ?>
</label>
<input id="email" name="email" type="email" required
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"
value="<?php echo htmlspecialchars($_POST['email'] ?? ''); ?>">
</div>
<div>
<label for="password" class="block text-sm font-medium text-gray-700">
<?php echo $currentContent['password']; ?>
</label>
<input id="password" name="password" type="password" required
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500">
</div>
<div class="flex items-center justify-between">
<a href="/forgot-password.php" class="text-sm text-blue-600 hover:text-blue-500">
<?php echo $currentContent['forgotPassword']; ?>
</a>
</div>
<div>
<button type="submit"
class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<?php echo $currentContent['login']; ?>
</button>
</div>
<div class="text-center">
<span class="text-sm text-gray-600">
<?php echo $currentContent['noAccount']; ?>
</span>
<a href="/register.php" class="ml-1 text-sm text-blue-600 hover:text-blue-500">
<?php echo $currentContent['signUp']; ?>
</a>
</div>
</form>
</div>
<!-- Language Toggle -->
<div class="text-center">
<button onclick="toggleLanguage()" class="text-sm text-gray-500 hover:text-gray-700">
<?php echo $language === 'fr' ? 'English' : 'Français'; ?>
</button>
</div>
<!-- Back to Home -->
<div class="text-center">
<a href="/" class="text-sm text-blue-600 hover:text-blue-500">
<?php echo $currentContent['backToHome']; ?>
</a>
</div>
</div>
<script>
function toggleLanguage() {
const currentLang = '<?php echo $language; ?>';
const newLang = currentLang === 'fr' ? 'en' : 'fr';
window.location.href = `?lang=${newLang}`;
}
</script>
</body>
</html>