2022-06-14 23:36:26 +02:00
|
|
|
<?php
|
|
|
|
$page = "index";
|
|
|
|
include "script.php";
|
2023-07-02 19:30:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-02 19:37:53 +02:00
|
|
|
|
2022-07-10 18:08:53 +02:00
|
|
|
//CAS
|
|
|
|
require_once("../phpCAS-1.3.6/CAS.php");
|
|
|
|
|
2023-07-02 17:04:33 +02:00
|
|
|
|
2022-07-10 18:08:53 +02:00
|
|
|
// Initialize phpCAS
|
|
|
|
phpCAS::client(CAS_VERSION_2_0, "cas.insa-toulouse.fr", 443, 'cas', true);
|
|
|
|
|
|
|
|
// For production use set the CA certificate that is the issuer of the cert
|
|
|
|
// on the CAS server and uncomment the line below
|
2022-10-27 19:52:08 +02:00
|
|
|
//phpCAS::setCasServerCACert($cas_server_ca_cert_path);
|
|
|
|
phpCAS::setNoCasServerValidation();
|
2022-07-10 18:08:53 +02:00
|
|
|
|
|
|
|
// force CAS authentication
|
|
|
|
phpCAS::forceAuthentication();
|
2022-06-14 23:36:26 +02:00
|
|
|
|
2022-07-10 18:08:53 +02:00
|
|
|
// at this step, the user has been authenticated by the CAS server
|
|
|
|
// and the user's login name can be read with phpCAS::getUser().
|
2023-07-02 17:04:33 +02:00
|
|
|
$pseudo = phpCAS::getUser();
|
2022-07-10 18:08:53 +02:00
|
|
|
|
|
|
|
if(!isset($_SESSION['id'])) {
|
|
|
|
$req = $db->prepare("SELECT id FROM admin WHERE pseudo = ?");
|
|
|
|
$req->execute(array($pseudo));
|
|
|
|
$user_exist = $req->rowcount();
|
|
|
|
if ($user_exist == 1) {
|
2022-06-14 23:36:26 +02:00
|
|
|
while ($user_login = $req->fetch()) {
|
2022-07-10 18:08:53 +02:00
|
|
|
$_SESSION['id'] = $user_login['id'];
|
|
|
|
header('Refresh:0');
|
2022-06-14 23:36:26 +02:00
|
|
|
}
|
|
|
|
} else {
|
2022-07-10 18:08:53 +02:00
|
|
|
$error = "Identifiant invalide !";
|
2022-06-14 23:36:26 +02:00
|
|
|
}
|
|
|
|
}
|
2022-07-10 18:08:53 +02:00
|
|
|
|
|
|
|
if(isset($_POST['login'])) {
|
|
|
|
session_start();
|
|
|
|
$_SESSION = array();
|
|
|
|
session_destroy();
|
|
|
|
header('Refresh:0');
|
2023-07-02 19:37:53 +02:00
|
|
|
}
|
2023-07-02 19:30:06 +02:00
|
|
|
|
|
|
|
|
2022-06-14 23:36:26 +02:00
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<title>Admin / index</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
2022-06-15 17:35:34 +02:00
|
|
|
<main>
|
2022-06-14 23:36:26 +02:00
|
|
|
<?php
|
|
|
|
if(isset($_SESSION['id'])) {
|
|
|
|
echo "Connecté sous l'identifiant : ".$user['pseudo'];
|
2022-06-15 21:19:49 +02:00
|
|
|
echo "<br><br>Accès : ";
|
|
|
|
switch ($user['perm']) {
|
|
|
|
case 0:
|
|
|
|
echo "<font color='green'>GDA</font>";
|
|
|
|
break;
|
|
|
|
case 1:
|
2022-07-24 19:54:06 +02:00
|
|
|
echo "<font color='#3498DB'>ville</font>";
|
2022-06-15 21:19:49 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2022-07-24 19:54:06 +02:00
|
|
|
echo "<font color='orange'>bureau</font>";
|
|
|
|
break;
|
|
|
|
case 3:
|
2022-06-15 21:19:49 +02:00
|
|
|
echo "<font color='red'>Admin</font>";
|
|
|
|
break;
|
|
|
|
}
|
2023-04-16 15:22:50 +02:00
|
|
|
echo "<br> Si l'onglet que vous recherchez n'est pas disponible, demandez avec amour et volupté une élévation d'acces à un respo web.";
|
2023-05-17 19:09:01 +02:00
|
|
|
|
2022-06-14 23:36:26 +02:00
|
|
|
} else {
|
|
|
|
?>
|
|
|
|
<form method="POST">
|
2022-06-15 21:00:54 +02:00
|
|
|
<input type="submit" name="login" value="Se connecter" class="submit">
|
2022-06-14 23:36:26 +02:00
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
if(isset($error)) {
|
|
|
|
echo "<font color='red'>".$error."</font>";
|
|
|
|
}
|
|
|
|
?>
|
2023-05-17 19:09:01 +02:00
|
|
|
|
|
|
|
|
2022-06-15 17:35:34 +02:00
|
|
|
</main>
|
2022-06-14 23:36:26 +02:00
|
|
|
</body>
|
|
|
|
</html>
|