| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- require_once '../includes/config.php';
- require_once '../includes/database.php';
- require_once '../includes/auth.php';
- // 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>
|