| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- require_once '../includes/config.php';
- require_once '../includes/database.php';
- require_once '../includes/auth.php';
- // Start session for language preference
- if (session_status() === PHP_SESSION_NONE) {
- session_start();
- }
- // Initialize translation system
- try {
- $translation = Translation::getInstance();
- } catch (Exception $e) {
- // Fallback to basic translations if translation system fails
- $translation = null;
- }
- // Include LDAP class if LDAP is enabled
- if (LDAP_ENABLED) {
- require_once '../includes/ldap.php';
- }
- $auth = new Auth();
- if ($auth->isLoggedIn()) {
- header('Location: index.php');
- exit;
- }
- $errors = [];
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $username = trim($_POST['username'] ?? '');
- $password = $_POST['password'] ?? '';
-
- if (empty($username) || empty($password)) {
- $errors[] = 'Please enter both username and password';
- } elseif ($auth->login($username, $password)) {
- header('Location: index.php');
- exit;
- } else {
- $errors[] = 'Invalid username or password';
- }
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Admin Login - <?php echo SITE_TITLE; ?></title>
- <link rel="stylesheet" href="../css/style.css">
- </head>
- <body class="login-page">
- <div class="container">
- <div class="login-form">
- <h1>Admin Login</h1>
-
- <?php if (LDAP_ENABLED): ?>
- <div class="auth-info">
- <p class="ldap-notice">
- <strong>LDAP Authentication Enabled</strong><br>
- Please login with your directory credentials.
- </p>
- </div>
- <?php endif; ?>
-
- <?php if (!empty($errors)): ?>
- <div class="alert alert-error">
- <?php foreach ($errors as $error): ?>
- <p><?php echo htmlspecialchars($error); ?></p>
- <?php endforeach; ?>
- </div>
- <?php endif; ?>
-
- <form method="post">
- <div class="form-group">
- <label for="username">
- <?php echo LDAP_ENABLED ? 'Directory Username:' : 'Username:'; ?>
- </label>
- <input type="text" id="username" name="username" required
- placeholder="<?php echo LDAP_ENABLED ? 'Enter your directory username' : 'Enter username'; ?>">
- </div>
-
- <div class="form-group">
- <label for="password">
- <?php echo LDAP_ENABLED ? 'Directory Password:' : 'Password:'; ?>
- </label>
- <input type="password" id="password" name="password" required
- placeholder="<?php echo LDAP_ENABLED ? 'Enter your directory password' : 'Enter password'; ?>">
- </div>
-
- <button type="submit" class="btn btn-primary">Login</button>
- </form>
- </div>
- </div>
- </body>
- </html>
|