<?php /** * Created by PhpStorm. * User: roessler * Date: 16/09/15 * Time: 1:32 PM */ require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'config/config.php'; if (isset($_POST['hdnAction'])) { if ($_POST['hdnAction'] == 'login') { $ldap = new ldap(); $result = $ldap->authenticate($_POST['txtUsername'], $_POST['txtPassword']); if ($result) { $_SESSION['authenticated'] = true; $_SESSION['username'] = $_POST['txtUsername']; if ($_POST['hdnRedirect'] != '') { header('location:' . $_POST['hdnRedirect']); } else { header('location:./admin/index.php'); } } else { echo "wrong credentials"; } } } else { if (isset($_GET['r'])) { $redirect = $_GET['r']; } else { $redirect = ''; }
<?php session_start(); include "./includes/templates/configuration.php"; include "includes/classes/auth.php"; $account = $_POST["account"]; $password = $_POST["password"]; $login_result = true; if ($account != "") { $ldap = new ldap($GLOBALS['config']['ldap_host'], $GLOBALS['config']['ldap_user_domain'], $GLOBALS['config']['ldap_dn']); $login_result = $ldap->authenticate($account, $password); if ($login_result == "ok") { $_SESSION['login'] = true; $_SESSION['name'] = $ldap->getFullName($account); header("Location: index.php"); } else { session_destroy(); } } ?> <!doctype html> <html lang="en-US"> <head> <meta http-equiv="X-UA-Compatible" content="IE=11"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta charset="utf-8"> <title>Login</title> <link rel="stylesheet" href="css/login.css" type="text/css">