psr12 fixes for new PHP_CodeSniffer (#4795)
[openemr.git] / portal / patient / fwk / libs / verysimple / Authentication / Auth401.php
blobf67e8dff35538b6caf47bdc8023463207fd6a232
1 <?php
3 /** @package verysimple::Authentication */
5 /**
6 * Auth404 provided 401 authentication
8 * @package verysimple::Authentication
9 * @author VerySimple Inc.
10 * @copyright 1997-2007 VerySimple, Inc.
11 * @license http://www.gnu.org/licenses/lgpl.html LGPL
12 * @version 1.0
15 class Auth401
17 /**
18 * Send 401 headers to the browser
20 * @param
21 * string message to output as "Basic realm" text/message (default "Login Required")
22 * @param
23 * bool true to terminate php after outputting headers (default true)
25 static function OutputHeaders($realm = "Login Required", $terminate = true)
27 header("WWW-Authenticate: Basic realm=\"" . $realm . "\"");
28 header("Status: 401 Unauthorized");
29 header("HTTP-Status: 401 Unauthorized");
30 if ($terminate) {
31 die();
35 /**
36 * Returns the server AUTH_USERNAME if provided or returns empty string
38 * @return string
40 static function GetUsername()
42 return isset($_SERVER ["PHP_AUTH_USER"]) ? $_SERVER ["PHP_AUTH_USER"] : "";
45 /**
46 * Returns the server AUTH_PASSWORD if provided or returns empty string
48 * @return string
50 static function GetPassword()
52 return isset($_SERVER ["PHP_AUTH_PW"]) ? $_SERVER ["PHP_AUTH_PW"] : "";