Limmat/s/authentication.php
2025-01-07 03:45:35 +01:00

46 lines
1.4 KiB
PHP

<?php
if(isset($_SESSION['auth']))
{
if(isset($_SESSION['loggedInUserRole'])){
$role = validate($_SESSION['loggedInUserRole']);
$id = validate($_SESSION['loggedInUserID']);
if($role != 'student'){
logoutSession();
redirect('../index.php', 'Zugriff verweigert', 'danger');
}
$query = "SELECT id, status, userid FROM tbl_students WHERE id='$id'";
$result = mysqli_query($conn, $query);
if($result) {
if(mysqli_num_rows($result) == 0){
logoutSession();
redirect('../index.php', 'Zugriff verweigert', 'danger');
}
else{
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
if($row['status'] == 'disabled'){
logoutSession();
redirect('../index.php', 'Das Konto ist deaktiviert', 'danger');
}
elseif($row['status'] == 'archived'){
logoutSession();
redirect('../index.php', 'Das Konto ist archiviert', 'danger');
}
}
}
else{
logoutSession();
redirect('../index.php', 'technischer Fehler', 'danger');
}
}
else
{
redirect('../index.php', 'Zugriff verweigert', 'danger');
}
}
else
{
redirect('../index.php', 'Bitte melde dich an', 'warning');
}
?>