Public Member Functions | |
authValidate ($headers=null) | |
authFailed () |
Definition at line 32 of file Http.php.
authFailed | ( | ) |
authValidate | ( | $ | headers = null |
) |
Definition at line 34 of file Http.php.
00035 { 00036 if(!is_null($headers)) { 00037 $_SERVER = $headers; 00038 } 00039 00040 $user = ''; 00041 $pass = ''; 00042 // moshe's fix for CGI 00043 if (empty($_SERVER['HTTP_AUTHORIZATION'])) { 00044 foreach ($_SERVER as $k=>$v) { 00045 if (substr($k, -18)==='HTTP_AUTHORIZATION' && !empty($v)) { 00046 $_SERVER['HTTP_AUTHORIZATION'] = $v; 00047 break; 00048 } 00049 } 00050 } 00051 00052 if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { 00053 $user = $_SERVER['PHP_AUTH_USER']; 00054 $pass = $_SERVER['PHP_AUTH_PW']; 00055 } 00056 // IIS Note:: For HTTP Authentication to work with IIS, 00057 // the PHP directive cgi.rfc2616_headers must be set to 0 (the default value). 00058 elseif (!empty($_SERVER['HTTP_AUTHORIZATION'])) { 00059 $auth = $_SERVER['HTTP_AUTHORIZATION']; 00060 list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1))); 00061 } 00062 elseif (!empty($_SERVER['Authorization'])) { 00063 $auth = $_SERVER['Authorization']; 00064 list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1))); 00065 } 00066 00067 if(!$user || !$pass) { 00068 $this->authFailed(); 00069 } 00070 00071 return array($user, $pass); 00072 }