PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > PHP_AUTH_* doesn't work on Apache?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
PHP_AUTH_* doesn't work on Apache?

Réponse
 
LinkBack Outils de la discussion
Vieux 05/11/2007, 23h33   #1
yawnmoth
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut PHP_AUTH_* doesn't work on Apache?

I was trying to test the following PHP script and am having some
difficulty:

<?php
if (empty($_SERVER['PHP_AUTH_USER']) ||
empty($_SERVER['PHP_AUTH_PW']))
{
header('WWW-Authenticate: Basic realm="Admin Control Panel"');
header('HTTP/1.0 401 Unauthorized');
exit;
}

echo 'PHP_AUTH_USER:
'.htmlspecialchars($_SERVER['PHP_AUTH_USER']).'<br />';
echo 'PHP_AUTH_PW: '.htmlspecialchars($_SERVER['PHP_AUTH_PW']);
?>

When I try it on Abyss web server what happens is that I enter "test"
as my username / password and then it echoes them back to me. On
Apache, it just keeps prompting me for the password. It's as though
PHP_AUTH_* is never being set. Any ideas as to why this is and what
I'd need to do to fix it?

  Réponse avec citation
Vieux 06/11/2007, 02h24   #2
Justin Koivisto
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP_AUTH_* doesn't work on Apache?

yawnmoth wrote:
> I was trying to test the following PHP script and am having some
> difficulty:
>
> <?php
> if (empty($_SERVER['PHP_AUTH_USER']) ||
> empty($_SERVER['PHP_AUTH_PW']))
> {
> header('WWW-Authenticate: Basic realm="Admin Control Panel"');
> header('HTTP/1.0 401 Unauthorized');
> exit;
> }
>
> echo 'PHP_AUTH_USER:
> '.htmlspecialchars($_SERVER['PHP_AUTH_USER']).'<br />';
> echo 'PHP_AUTH_PW: '.htmlspecialchars($_SERVER['PHP_AUTH_PW']);
> ?>
>
> When I try it on Abyss web server what happens is that I enter "test"
> as my username / password and then it echoes them back to me. On
> Apache, it just keeps prompting me for the password. It's as though
> PHP_AUTH_* is never being set. Any ideas as to why this is and what
> I'd need to do to fix it?
>


I know, I know... personal plug = bad taste.... However, I have done
some work with basic auth through apache/php and did a quick write up:
http://koivi.com/php-http-auth/

--
Posted via a free Usenet account from http://www.teranews.com

  Réponse avec citation
Vieux 06/11/2007, 04h10   #3
NC
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP_AUTH_* doesn't work on Apache?

On Nov 5, 3:33 pm, yawnmoth <terra1...@yahoo.com> wrote:
>
> I was trying to test the following PHP script and am having
> some difficulty:
>
> if (empty($_SERVER['PHP_AUTH_USER']) ||
> empty($_SERVER['PHP_AUTH_PW']))

....
> When I try it on Abyss web server what happens is that I enter
> "test" as my username / password and then it echoes them back
> to me. On Apache, it just keeps prompting me for the password.
> It's as though PHP_AUTH_* is never being set. Any ideas as to
> why this is and what I'd need to do to fix it?


Most likely, your PHP is configured as CGI/FastCGI. HTTP
authentication, on the other hand, is only supported if PHP is
configured as an Apache module. Documentation says it quite clearly:

The HTTP Authentication hooks in PHP are only available when
it is running as an Apache module and is hence not available
in the CGI version.

http://www.php.net/features.http-auth

Another possibility is that your Apache installation does not have an
authorization module.

Cheers,
NC

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h23.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10171 seconds with 11 queries