-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthentication.php
executable file
·40 lines (33 loc) · 1.73 KB
/
authentication.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
include "./config";
// Check to see if the user is signed in.
session_start();
if ($_SESSION['authid'] == "dropauth") { // Check to see if the user is already signed in with DropAuth.
$username = $_SESSION['username'];
} else {
if ($config["use_landing_page"] == true) { // Check to see if the configuration value to use an intermediate landing page is active.
header("Location: ./landing.php");
} else {
header("Location: " . $config["login_page"]);
}
exit(); // Quit loading the rest of the page.
}
if ($admin_only == true or $config["access"] == "admin") { // Check to see if only the admin is allowed to access this page.
if ($config["admin_user"] != "") { // Check to see if a admin username has been set.
if ($username != $config["admin_user"]) { // Check to see if the current user's username matches the required username.
echo "Permission denied"; // If not, deny the user access to this page.
exit(); // Quit loading the rest of the page.
}
}
} else if ($config["access"] == "whitelist") { // Check to see if only whitelisted users are allowed to access this page.
if (!in_array($username, $config["whitelist"]) and $username != $config["admin_user"]) { // Check to see if the current user is either an admin, or in the list of whitelisted users.
echo "Permission denied"; // If not, deny the user access to this page.
exit(); // Quit loading the rest of the page.
}
} else if ($config["access"] == "all") { // Everyone with a username is allowed to access this page.
if ($username == "") {
echo "Permission denied"; // If not, deny the user access to this page.
exit(); // Quit loading the rest of the page.
}
}
?>