Richard Bowser Posted March 9, 2007 Share Posted March 9, 2007 Reading the PHP manual, I believe it is possible to use digest mode authentication in a PHP script. This is just a belief because – although Example 34.2 illustrates it – nowhere, in the PHP manual, or at php.net is the function http_digest_parse() documented. If this is wrong PLEASE tell me! Here’s my situation: I copied the example verbatim and tried to run it, with the example’s user names & passwords (both pairs). Twice I had failures. The dialog box did appear in each case of login attempt, but each time the call to http_digest_parse($_SERVER['PHP_AUTH_DIGEST']) returned a binary 1 (for Failure). This was no shock to me, since this was only my first try. I went to look up the function and found: nothing. Whatsoever. A brick wall dead-end. I don't want to act like"clueless Lewis", but I guess here I really am! Richard B Quote Link to comment Share on other sites More sharing options...
ShogunWarrior Posted March 9, 2007 Share Posted March 9, 2007 The function http_digest_parse is NOT a built-in function, it was just a function the PHP.net example-writer wrote to clean up their example code. Here it is: // function to parse the http auth header function http_digest_parse($txt) { // protect against missing data $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); $data = array(); preg_match_all('@(\w+)=(?[\'"])([^\2]+)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); foreach ($matches as $m) { $data[$m[1]] = $m[3] ? $m[3] : $m[4]; unset($needed_parts[$m[1]]); } return $needed_parts ? false : $data; } If the function returned 1 then it is probably successful. http://us3.php.net/features.http-auth Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.