forked from proche-rainmaker/phplicensewatcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.php
25 lines (21 loc) · 994 Bytes
/
auth.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
<?php
################################################################################################
# This script is used for authenticating users with PHPLicensewatcher. It is implemented
# using Basic HTTP authentication. In order for this script to do anything both admin
# username and password have to be set. If they are not we assume that no authentication
# is needed
################################################################################################
if ( isset($adminusername) && isset($adminpassword) ) {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="PHPLicenseWatcher Admin"');
header('HTTP/1.0 401 Unauthorized');
echo 'Sorry. This feature requires authorization';
exit;
} else {
if ( ! ($adminusername == $_SERVER['PHP_AUTH_USER'] && $adminpassword == $_SERVER['PHP_AUTH_PW']) ){
header('WWW-Authenticate: Basic realm="PHPLicenseWatcher Admin"');
header('HTTP/1.0 401 Unauthorized');
}
}
}
?>