| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- require_once '../includes/config.php';
- require_once '../includes/database.php';
- require_once '../includes/auth.php';
- // Start session for language preference
- session_start();
- // Initialize translation system
- try {
- $translation = Translation::getInstance();
- } catch (Exception $e) {
- // Fallback to basic translations if LDAP 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>
|