feat: add MVC base, with auth to ldap
This commit is contained in:
42
controllers/auth.php
Normal file
42
controllers/auth.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require_once __DIR__ . '/../models/LDAPAuth.php';
|
||||
|
||||
class AuthController
|
||||
{
|
||||
private $auth_model;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth_model = new LDAPAuth();
|
||||
}
|
||||
|
||||
public function login()
|
||||
{
|
||||
if (isset($_POST['user_pseudo']) && isset($_POST['user_password'])) {
|
||||
$result = $this->auth_model->authenticate(
|
||||
$_POST['user_pseudo'],
|
||||
$_POST['user_password']
|
||||
);
|
||||
|
||||
if ($result['success']) {
|
||||
$_SESSION['login'] = true;
|
||||
$_SESSION['user_pseudo'] = $_POST['user_pseudo'];
|
||||
$_SESSION['is_admin'] = $result['is_admin'];
|
||||
$_SESSION['ldap_token'] = base64_encode($_POST['user_pseudo'] . ':' . $_POST['user_password']);
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
} else {
|
||||
$error_message = 'Identifiants incorrects';
|
||||
require_once __DIR__ . '/views/auth.php';
|
||||
}
|
||||
} else {
|
||||
require_once __DIR__ . '/views/auth.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
session_start(); // Assure-toi que la session est bien démarrée
|
||||
$controller = new AuthController();
|
||||
$controller->login();
|
||||
60
controllers/controllerAdmin.php
Normal file
60
controllers/controllerAdmin.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
function listAllOU()
|
||||
{
|
||||
if (session_status() == PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Vérifier si le token est présent dans la session
|
||||
if (!isset($_SESSION['ldap_token'])) {
|
||||
die("Token d'authentification manquant. Veuillez vous reconnecter.");
|
||||
}
|
||||
|
||||
$ldapconn = ldap_connect("ldap://intranet.epul3a.local")
|
||||
or die("Could not connect to LDAP server.");
|
||||
|
||||
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
|
||||
|
||||
// Décoder le token et extraire les informations
|
||||
$token = base64_decode($_SESSION['ldap_token']);
|
||||
if ($token === false) {
|
||||
die("Token d'authentification invalide.");
|
||||
}
|
||||
|
||||
list($ldap_user, $ldap_password) = explode(':', $token);
|
||||
if (count(explode(':', $token)) !== 2) {
|
||||
die("Format de token invalide.");
|
||||
}
|
||||
|
||||
$ldap_user = "CN=$ldap_user,CN=Users,DC=epul3a,DC=local";
|
||||
|
||||
if (!@ldap_bind($ldapconn, $ldap_user, $ldap_password)) {
|
||||
die("Could not bind to LDAP server: " . ldap_error($ldapconn));
|
||||
}
|
||||
|
||||
$searchBase = "DC=epul3a,DC=local";
|
||||
$filter = "(objectClass=organizationalUnit)";
|
||||
$attributes = array("ou", "distinguishedName");
|
||||
|
||||
$result = @ldap_search($ldapconn, $searchBase, $filter, $attributes);
|
||||
|
||||
if ($result) {
|
||||
$entries = ldap_get_entries($ldapconn, $result);
|
||||
echo "<h3>Liste des OUs:</h3>";
|
||||
if ($entries['count'] > 0) {
|
||||
foreach ($entries as $key => $entry) {
|
||||
if (is_numeric($key)) {
|
||||
echo "OU: " . $entry['ou'][0] . "<br>";
|
||||
echo "DN: " . $entry['distinguishedname'][0] . "<br><br>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "Aucune OU trouvée.";
|
||||
}
|
||||
} else {
|
||||
echo "Error: " . ldap_error($ldapconn);
|
||||
}
|
||||
|
||||
ldap_close($ldapconn);
|
||||
}
|
||||
33
controllers/create_user.php
Normal file
33
controllers/create_user.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// Check if user is logged in and is admin
|
||||
if (!isset($_SESSION["login"]) || !$_SESSION["is_admin"]) {
|
||||
header("Location: ../index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Initialize form variables
|
||||
$nom = isset($_POST['nom']) ? $_POST['nom'] : '';
|
||||
$prenom = isset($_POST['prenom']) ? $_POST['prenom'] : '';
|
||||
$pseudo = isset($_POST['pseudo']) ? $_POST['pseudo'] : '';
|
||||
$email = isset($_POST['email']) ? $_POST['email'] : '';
|
||||
$password = isset($_POST['password']) ? $_POST['password'] : '';
|
||||
|
||||
// Display form
|
||||
echo "<h2>Création d'un utilisateur</h2>";
|
||||
echo "<form method=post>";
|
||||
echo "Nom <input type=text name=nom value='$nom' required><br>";
|
||||
echo "Prénom <input type=text name=prenom value='$prenom' required><br>";
|
||||
echo "Nom d'utilisateur <input type=text name=pseudo value='$pseudo' required><br>";
|
||||
echo "E-Mail <input type=text name=email value='$email' required><br>";
|
||||
echo "Mot de passe <input type=password name=password value='$password' required><br>";
|
||||
echo "Rôle dans l'OU <select name=role>";
|
||||
echo "<option value='user'>Utilisateur standard</option>";
|
||||
echo "<option value='admin'>Administrateur</option>";
|
||||
echo "</select><br>";
|
||||
echo "<input type=submit value='Créer'>";
|
||||
echo "</form>";
|
||||
|
||||
require_once 'controllerAdmin.php';
|
||||
listAllOU();
|
||||
19
divers/connexion.php
Normal file
19
divers/connexion.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$host = 'localhost'; // ou l'adresse IP du serveur MariaDB
|
||||
$dbname = 'test'; // nom de votre base de donn<6E>es
|
||||
$username = 'root'; // nom d'utilisateur MariaDB
|
||||
$password = 'root'; // mot de passe pour l'utilisateur
|
||||
try {
|
||||
// Cr<43>ation d'une instance PDO pour la connexion <20> la base de donn<6E>es
|
||||
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
|
||||
// Configuration du mode d'erreur de PDO pour les exceptions
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
echo "Connexion r<>ussie <20> MariaDB avec PDO!";
|
||||
} catch (PDOException $e) {
|
||||
echo "<EFBFBD>chec de la connexion : " . $e->getMessage();
|
||||
}
|
||||
|
||||
$stmt = $pdo->query("SELECT * FROM users");
|
||||
$users = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
print_r($users);
|
||||
?>
|
||||
13
divers/hello.aspx
Normal file
13
divers/hello.aspx
Normal file
@@ -0,0 +1,13 @@
|
||||
<%@ Page Language="VB" %>
|
||||
<%
|
||||
HelloWorld.Text = "Hello World"
|
||||
%>
|
||||
<html>
|
||||
<head>
|
||||
<title>ASP.NET Hello World</title>
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<p><asp:label id="HelloWorld"
|
||||
runat="server" /></p>
|
||||
</body>
|
||||
</html>
|
||||
6
divers/ldap.php
Normal file
6
divers/ldap.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$ldapconn = ldap_connect("ldap://intranet.epul3a.local")
|
||||
or die("Impossible de se connecter au serveur LDAP");
|
||||
if ($ldapconn) {
|
||||
echo "Connexion réussie!";
|
||||
}
|
||||
23
index.php
Normal file
23
index.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
session_start();
|
||||
|
||||
// Si l'utilisateur n'est pas connecté et qu'il n'essaie pas de se connecter
|
||||
if (!isset($_SESSION["login"]) && !isset($_GET['action'])) {
|
||||
require_once __DIR__ . '/views/auth.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Si l'utilisateur essaie de se connecter
|
||||
if (isset($_GET['action']) && $_GET['action'] === 'login') {
|
||||
require_once __DIR__ . '/controllers/auth.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Si l'utilisateur est connecté, afficher le menu
|
||||
if (isset($_SESSION["login"]) && $_SESSION["login"] === true) {
|
||||
require_once __DIR__ . '/views/menu.php';
|
||||
exit;
|
||||
}
|
||||
52
models/LDAPAuth.php
Normal file
52
models/LDAPAuth.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
class LDAPAuth
|
||||
{
|
||||
private $ldap_server;
|
||||
private $domain;
|
||||
private $FISA;
|
||||
private $admin;
|
||||
private $ad;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ldap_server = 'ldap://intranet.epul3a.local';
|
||||
$this->domain = 'intranet.epul3a.local';
|
||||
$this->FISA = 'OU=3AFISA,DC=epul3a,DC=local';
|
||||
$this->admin = 'CN=Users,DC=epul3a,DC=local';
|
||||
}
|
||||
|
||||
public function connect()
|
||||
{
|
||||
$this->ad = ldap_connect($this->ldap_server)
|
||||
or die("Impossible de se connecter au LDAP");
|
||||
ldap_set_option($this->ad, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
ldap_set_option($this->ad, LDAP_OPT_REFERRALS, 0);
|
||||
}
|
||||
|
||||
public function authenticate($user_pseudo, $user_password)
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
$ldap_user_3afisa = "CN=$user_pseudo,$this->FISA";
|
||||
$ldap_user_admin = "CN=$user_pseudo,$this->admin";
|
||||
|
||||
$bind_3afisa = @ldap_bind($this->ad, $ldap_user_3afisa, $user_password);
|
||||
$bind_admin = false;
|
||||
|
||||
if (!$bind_3afisa) {
|
||||
$bind_admin = @ldap_bind($this->ad, $ldap_user_admin, $user_password);
|
||||
}
|
||||
|
||||
if ($bind_3afisa || $bind_admin) {
|
||||
return ['success' => true, 'is_admin' => $bind_admin];
|
||||
}
|
||||
return ['success' => false];
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
if ($this->ad) {
|
||||
ldap_close($this->ad);
|
||||
}
|
||||
}
|
||||
}
|
||||
132
php_errors.log
Normal file
132
php_errors.log
Normal file
@@ -0,0 +1,132 @@
|
||||
[31-Jan-2025 14:48:30 UTC] PHP Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.users' doesn't exist in C:\Site\connexion.php:16
|
||||
Stack trace:
|
||||
#0 C:\Site\connexion.php(16): PDO->query('SELECT * FROM u...')
|
||||
#1 {main}
|
||||
thrown in C:\Site\connexion.php on line 16
|
||||
[31-Jan-2025 15:17:56 UTC] PHP Warning: Undefined array key "login" in C:\Site\menu.php on line 3
|
||||
[31-Jan-2025 15:17:57 UTC] PHP Warning: Undefined variable $user_pseudo in C:\Site\auth.php on line 29
|
||||
[31-Jan-2025 15:17:57 UTC] PHP Warning: Undefined variable $user_password in C:\Site\auth.php on line 30
|
||||
[31-Jan-2025 15:18:50 UTC] PHP Warning: Undefined variable $user_pseudo in C:\Site\auth.php on line 29
|
||||
[31-Jan-2025 15:18:50 UTC] PHP Warning: Undefined variable $user_password in C:\Site\auth.php on line 30
|
||||
[31-Jan-2025 15:29:03 UTC] PHP Warning: Undefined array key "login" in C:\Site\menu.php on line 3
|
||||
[31-Jan-2025 15:31:38 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 15:31:55 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 15:32:18 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 15:33:59 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 15:34:11 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 15:36:54 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 15:37:03 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 15:39:23 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 15:46:59 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 15:48:49 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 15:49:22 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 15:49:38 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 20
|
||||
[31-Jan-2025 16:05:43 UTC] PHP Warning: Undefined array key "login" in C:\Site\menu.php on line 3
|
||||
[31-Jan-2025 16:08:44 UTC] PHP Warning: Undefined array key "login" in C:\Site\menu.php on line 3
|
||||
[31-Jan-2025 16:12:08 UTC] PHP Warning: Undefined array key "login" in C:\Site\menu.php on line 3
|
||||
[02-Feb-2025 10:00:09 UTC] PHP Warning: Undefined array key "login" in C:\Site\menu.php on line 3
|
||||
[02-Feb-2025 10:03:11 UTC] PHP Warning: Undefined array key "login" in C:\Site\menu.php on line 3
|
||||
[02-Feb-2025 10:14:29 UTC] PHP Warning: Undefined array key "is_admin" in C:\Site\menu.php on line 10
|
||||
[02-Feb-2025 10:14:48 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 31
|
||||
[02-Feb-2025 10:16:23 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 31
|
||||
[02-Feb-2025 10:20:53 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 31
|
||||
[02-Feb-2025 10:24:33 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\auth.php on line 35
|
||||
[02-Feb-2025 10:46:39 UTC] PHP Warning: Undefined global variable $_SESSION in C:\Site\create_user.php on line 2
|
||||
[02-Feb-2025 10:46:39 UTC] PHP Warning: Trying to access array offset on value of type null in C:\Site\create_user.php on line 2
|
||||
[02-Feb-2025 10:50:51 UTC] PHP Warning: Undefined global variable $_SESSION in C:\Site\create_user.php on line 2
|
||||
[02-Feb-2025 10:50:51 UTC] PHP Warning: Trying to access array offset on value of type null in C:\Site\create_user.php on line 2
|
||||
[02-Feb-2025 15:44:25 UTC] PHP Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\Site\create_user.php on line 41
|
||||
[02-Feb-2025 15:44:25 UTC] PHP Warning: ldap_search(): Search: Operations error in C:\Site\create_user.php on line 44
|
||||
[02-Feb-2025 15:44:25 UTC] PHP Fatal error: Uncaught TypeError: ldap_get_entries(): Argument #2 ($result) must be of type LDAP\Result, bool given in C:\Site\create_user.php:45
|
||||
Stack trace:
|
||||
#0 C:\Site\create_user.php(45): ldap_get_entries(Object(LDAP\Connection), false)
|
||||
#1 C:\Site\create_user.php(32): listAllOU()
|
||||
#2 {main}
|
||||
thrown in C:\Site\create_user.php on line 45
|
||||
[02-Feb-2025 15:47:31 UTC] PHP Warning: ldap_search(): Search: Operations error in C:\Site\create_user.php on line 53
|
||||
[02-Feb-2025 15:48:22 UTC] PHP Warning: Undefined array key "user_password" in C:\Site\create_user.php on line 44
|
||||
[02-Feb-2025 15:48:22 UTC] PHP Warning: ldap_search(): Search: Operations error in C:\Site\create_user.php on line 52
|
||||
[02-Feb-2025 15:49:05 UTC] PHP Warning: Undefined array key "user_password" in C:\Site\create_user.php on line 44
|
||||
[02-Feb-2025 15:49:05 UTC] PHP Warning: ldap_search(): Search: Operations error in C:\Site\create_user.php on line 52
|
||||
[02-Feb-2025 16:22:37 UTC] PHP Fatal error: Uncaught Error: Class "LDAPController" not found in C:\Site\auth.php:3
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in C:\Site\auth.php on line 3
|
||||
[02-Feb-2025 16:22:39 UTC] PHP Fatal error: Uncaught Error: Class "LDAPController" not found in C:\Site\auth.php:3
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in C:\Site\auth.php on line 3
|
||||
[02-Feb-2025 16:22:39 UTC] PHP Fatal error: Uncaught Error: Call to undefined function listAllOU() in C:\Site\create_user.php:32
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in C:\Site\create_user.php on line 32
|
||||
[02-Feb-2025 16:23:07 UTC] PHP Fatal error: Uncaught Error: Class "LDAPController" not found in C:\Site\auth.php:3
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in C:\Site\auth.php on line 3
|
||||
[02-Feb-2025 16:24:12 UTC] PHP Warning: require_once(LDAPController.php): Failed to open stream: No such file or directory in C:\Site\auth.php on line 3
|
||||
[02-Feb-2025 16:24:12 UTC] PHP Fatal error: Uncaught Error: Failed opening required 'LDAPController.php' (include_path='.;C:\php\pear') in C:\Site\auth.php:3
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in C:\Site\auth.php on line 3
|
||||
[02-Feb-2025 16:24:36 UTC] PHP Warning: Undefined variable $user_pseudo in C:\Site\auth.php on line 6
|
||||
[02-Feb-2025 16:24:36 UTC] PHP Warning: Undefined variable $user_password in C:\Site\auth.php on line 6
|
||||
[02-Feb-2025 16:28:19 UTC] PHP Warning: require_once(classes/LDAPAuth.php): Failed to open stream: No such file or directory in C:\Site\auth.php on line 2
|
||||
[02-Feb-2025 16:28:19 UTC] PHP Fatal error: Uncaught Error: Failed opening required 'classes/LDAPAuth.php' (include_path='.;C:\php\pear') in C:\Site\auth.php:2
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in C:\Site\auth.php on line 2
|
||||
[02-Feb-2025 16:32:46 UTC] PHP Warning: require_once(classes/LDAPAuth.php): Failed to open stream: No such file or directory in C:\Site\vues\auth.php on line 2
|
||||
[02-Feb-2025 16:32:46 UTC] PHP Fatal error: Uncaught Error: Failed opening required 'classes/LDAPAuth.php' (include_path='.;C:\php\pear') in C:\Site\vues\auth.php:2
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in C:\Site\vues\auth.php on line 2
|
||||
[02-Feb-2025 16:32:47 UTC] PHP Warning: require_once(classes/LDAPAuth.php): Failed to open stream: No such file or directory in C:\Site\vues\auth.php on line 2
|
||||
[02-Feb-2025 16:32:47 UTC] PHP Fatal error: Uncaught Error: Failed opening required 'classes/LDAPAuth.php' (include_path='.;C:\php\pear') in C:\Site\vues\auth.php:2
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in C:\Site\vues\auth.php on line 2
|
||||
[02-Feb-2025 17:36:03 UTC] PHP Notice: session_start(): Ignoring session_start() because a session is already active in C:\Site\views\menu.php on line 2
|
||||
[02-Feb-2025 17:36:03 UTC] PHP Notice: session_start(): Ignoring session_start() because a session is already active in C:\Site\views\menu.php on line 2
|
||||
[02-Feb-2025 17:37:42 UTC] PHP Warning: ldap_search(): Search: Operations error in C:\Site\controllers\controllerAdmin.php on line 25
|
||||
[02-Feb-2025 17:39:26 UTC] PHP Warning: ldap_search(): Search: Operations error in C:\Site\controllers\controllerAdmin.php on line 25
|
||||
[02-Feb-2025 17:45:20 UTC] PHP Warning: Undefined array key "ldap_token" in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:45:20 UTC] PHP Deprecated: base64_decode(): Passing null to parameter #1 ($string) of type string is deprecated in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:45:20 UTC] PHP Warning: Undefined array key 1 in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:46:28 UTC] PHP Warning: Undefined array key "ldap_token" in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:46:28 UTC] PHP Deprecated: base64_decode(): Passing null to parameter #1 ($string) of type string is deprecated in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:46:28 UTC] PHP Warning: Undefined array key 1 in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:46:29 UTC] PHP Warning: Undefined array key "ldap_token" in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:46:29 UTC] PHP Deprecated: base64_decode(): Passing null to parameter #1 ($string) of type string is deprecated in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:46:29 UTC] PHP Warning: Undefined array key 1 in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:46:30 UTC] PHP Warning: Undefined array key "ldap_token" in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:46:30 UTC] PHP Deprecated: base64_decode(): Passing null to parameter #1 ($string) of type string is deprecated in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:46:30 UTC] PHP Warning: Undefined array key 1 in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:48:24 UTC] PHP Warning: Undefined array key "ldap_token" in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:48:24 UTC] PHP Deprecated: base64_decode(): Passing null to parameter #1 ($string) of type string is deprecated in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:48:24 UTC] PHP Warning: Undefined array key 1 in C:\Site\controllers\controllerAdmin.php on line 15
|
||||
[02-Feb-2025 17:51:43 UTC] PHP Warning: require_once(../models/LDAPAuth.php): Failed to open stream: No such file or directory in C:\Site\controllers\auth.php on line 2
|
||||
[02-Feb-2025 17:51:43 UTC] PHP Fatal error: Uncaught Error: Failed opening required '../models/LDAPAuth.php' (include_path='.;C:\php\pear') in C:\Site\controllers\auth.php:2
|
||||
Stack trace:
|
||||
#0 C:\Site\index.php(12): require_once()
|
||||
#1 {main}
|
||||
thrown in C:\Site\controllers\auth.php on line 2
|
||||
[02-Feb-2025 17:59:14 UTC] PHP Warning: require(/views/auth.php): Failed to open stream: No such file or directory in C:\Site\index.php on line 6
|
||||
[02-Feb-2025 17:59:14 UTC] PHP Fatal error: Uncaught Error: Failed opening required '/views/auth.php' (include_path='.;C:\php\pear') in C:\Site\index.php:6
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in C:\Site\index.php on line 6
|
||||
[02-Feb-2025 17:59:15 UTC] PHP Warning: require(/views/auth.php): Failed to open stream: No such file or directory in C:\Site\index.php on line 6
|
||||
[02-Feb-2025 17:59:15 UTC] PHP Fatal error: Uncaught Error: Failed opening required '/views/auth.php' (include_path='.;C:\php\pear') in C:\Site\index.php:6
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in C:\Site\index.php on line 6
|
||||
[02-Feb-2025 18:02:55 UTC] PHP Notice: session_start(): Ignoring session_start() because a session is already active in C:\Site\controllers\auth.php on line 38
|
||||
[02-Feb-2025 18:03:27 UTC] PHP Notice: session_start(): Ignoring session_start() because a session is already active in C:\Site\controllers\auth.php on line 38
|
||||
[02-Feb-2025 18:04:48 UTC] PHP Notice: session_start(): Ignoring session_start() because a session is already active in C:\Site\controllers\auth.php on line 38
|
||||
[02-Feb-2025 18:09:49 UTC] PHP Notice: session_start(): Ignoring session_start() because a session is already active in C:\Site\controllers\auth.php on line 2
|
||||
[02-Feb-2025 18:09:49 UTC] PHP Notice: session_start(): Ignoring session_start() because a session is already active in C:\Site\controllers\auth.php on line 40
|
||||
[02-Feb-2025 18:11:56 UTC] PHP Notice: session_start(): Ignoring session_start() because a session is already active in C:\Site\controllers\auth.php on line 2
|
||||
[02-Feb-2025 18:11:56 UTC] PHP Notice: session_start(): Ignoring session_start() because a session is already active in C:\Site\controllers\auth.php on line 40
|
||||
[02-Feb-2025 18:14:05 UTC] PHP Notice: session_start(): Ignoring session_start() because a session is already active in C:\Site\controllers\auth.php on line 2
|
||||
[02-Feb-2025 18:14:05 UTC] PHP Notice: session_start(): Ignoring session_start() because a session is already active in C:\Site\controllers\auth.php on line 40
|
||||
49
views/auth.php
Normal file
49
views/auth.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Authentification</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form method="post" action="/index.php?action=login">
|
||||
<label for="user_pseudo">Votre identifiant:</label>
|
||||
<input type="text" id="user_pseudo" name="user_pseudo" required><br>
|
||||
|
||||
<label for="user_password">Votre mot de passe:</label>
|
||||
<input type="password" id="user_password" name="user_password" required><br>
|
||||
|
||||
<input type="submit" value="Connexion">
|
||||
</form>
|
||||
<?php if (isset($error_message)): ?>
|
||||
<div class="error"><?php echo $error_message; ?></div>
|
||||
<?php endif; ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<!--
|
||||
/*
|
||||
DistinguishedName : CN=Administrator,CN=Users,DC=epul3a,DC=local
|
||||
Enabled : True
|
||||
GivenName :
|
||||
Name : Administrator
|
||||
ObjectClass : user
|
||||
ObjectGUID : 942805f8-904c-4393-ab28-38325a72450d
|
||||
SamAccountName : Administrator
|
||||
SID : S-1-5-21-2676391027-398497314-3097492335-500
|
||||
Surname :
|
||||
UserPrincipalName :
|
||||
|
||||
DistinguishedName : CN=Ali Gathor,OU=3AFISA,DC=epul3a,DC=local
|
||||
Enabled : True
|
||||
GivenName : Ali
|
||||
Name : Ali Gathor
|
||||
ObjectClass : user
|
||||
ObjectGUID : 5c2f554a-5157-473d-bb21-2868e29bf8f4
|
||||
SamAccountName : a.gathor
|
||||
SID : S-1-5-21-2676391027-398497314-3097492335-1106
|
||||
Surname : Gathor
|
||||
UserPrincipalName : a.gathor@epul3a.local
|
||||
*/ -->
|
||||
17
views/menu.php
Normal file
17
views/menu.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
if (!isset($_SESSION["login"]) || $_SESSION["login"] !== true) {
|
||||
header('Location: auth.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
echo "Bienvenue " . $_SESSION["user_pseudo"];
|
||||
|
||||
if ($_SESSION["is_admin"]) {
|
||||
echo "<h2>Admin Dashboard</h2>";
|
||||
echo "<a href='controllers/create_user.php'>Créer un utilisateur</a><br>";
|
||||
echo "<a href='controllers/modify_user.php'>Modifier un utilisateur</a><br>";
|
||||
echo "<a href='controllers/delete_user.php'>Supprimer un utilisateur</a><br>";
|
||||
} else {
|
||||
echo "<h2>Utilisateur Standard</h2>";
|
||||
echo "<p>Vous pouvez consulter votre profil.</p>";
|
||||
}
|
||||
Reference in New Issue
Block a user