Toon posts:

[PHP] php_auth_user probleem

Pagina: 1
Acties:

Verwijderd

Topicstarter
he ik heb het volgende vage probleem:
Ik heb hier lokaal een opzet voor een website gemaakt getest (en werkend bevonden :P) en was helemaal blij, heb alleen zelf geen 24/7 webserver mogelijkheid dus ik heb de hele boel naar een vriend van me geupt. Hij databaseje gedraaid ik alles daarheen gegooid, dirs komen overheen nix geen hoofdletters gebruikt enzo maar het wil niet werken :(

Mijn login.php vind dus echt van niet :(
Hij ziet er als volgt uit:
code:
1
2
3
4
5
6
7
8
if (!isset($PHP_AUTH_USER)) {

header("WWW-Authenticate: Basic realm=\"Dodging Bullets || Members Logon\"");
header("HTTP/1.0 401 Unauthorized");
echo( "Ik heb helemaal geen cancel gedrukt! :(" );
exit;

} else{ Mysql meuk..

lokaal gaat het goed maar als ik bij hem de login.php aanroep krijg ik direct de echo: Ik heb helemaal geen cancel gedrukt! :( te zien, zonder dat het popup schermpje om je user/pass in te voeren is verschenen?

whelp??!!

  • a casema user
  • Registratie: Januari 2000
  • Laatst online: 11-09 10:39
ik heb ff copy/paste je code gedaan bij mij en hier werkt die hoor.

http://www.superuser.nl/~sander/test.php

Taaaa taa taa taaaa taa taa ta taaataaaaa.


  • TheMrH
  • Registratie: April 2000
  • Laatst online: 01-09 22:45
Je gebruikt bij je vriend zekers IIS? Die filterd je headers, moet je hem of nph..... noemen (dus nph_login.php, nph van non parsed headers), of een andere header sturen (of beide, weet het niet meer...)

The box said 'requires Windows 95 or better', so I installed Linux...


Verwijderd

Topicstarter
He thnx a casema user, blij dat ie bij jou wel werkt, dan ligt het niet aan mijn script in iedergeval :)

ik denk dat ik al weet wat het is...
"Also note that this does not work using Microsoft's IIS server and the CGI version of PHP due to a limitation of IIS."

Ben heel bang dat hij idd op een IIS server draaid, iemand suggesties wat ik nu wel kan doen? (die nph_loging.php werkt helaas niet :'()

Verwijderd

Topicstarter
Owkee ik ben een stapje verder! Ik heb nu deze code gebruikt:
code:
1
2
3
4
5
6
7
8
9
10
if (!isset($PHP_AUTH_USER)) {
    header("WWW-Authenticate: Basic realm=\"Dodging Bullets || Members Logon\""); 
    if (ereg("Microsoft", $SERVER_SOFTWARE)) 
    header("Status: 401 Unauthorized"); 
    else 
    header("HTTP/1.0 401 Unauthorized"); 
    echo "Authorization Required."; 
    exit; 
    
    } else{ Mysql meuk...

Maar....
Ik krijg nu een popup met in de title balk: Connect to server.gameoverlan.lokaal, in het grijze vlak Connect to dodgingbullets.matchless.nl (dat is de server waar alles op staat) en als ik wil inloggen typ ik netjes username/pass in en dan krijg ik in het username textvak automatisch T-BIRD\IceFlame (IceFlame is username en T-BIRD is de naam van mijn pc?) hij logt dus niet in??
Tevens mis ik ook de Basic-Realm text die ik zelf heb gezet? Ik snap er echt helemaal niks van :'(

  • TheMrH
  • Registratie: April 2000
  • Laatst online: 01-09 22:45
Okay, ff een quote uit de user contributed notes bij de PHP manual (http://www.php.net/manual/en/features.http-auth.php):
I found a way to do the Basic Authentication on IIS anyway.

You have to disable the built-in Authentication from IIS first to make it
wotk though (only enable "Allow Anonymous Access", disable the
other Authentication methods).

Here's a code extract that works on IIS as well as on other webservers
(like Apache):<PRE>

if ($PHP_AUTH_USER == "" && $PHP_AUTH_PW == ""
&&
ereg("^Basic ", $HTTP_AUTHORIZATION)) {
list($PHP_AUTH_USER, $PHP_AUTH_PW) =
explode(":", base64_decode(substr($HTTP_AUTHORIZATION,
6)));
}
$authenticated = 0;
if ($PHP_AUTH_USER != "" || $PHP_AUTH_PW != "") {
//put your authentication here (e.g. database lookup)
$authenticated = ($PHP_AUTH_USER == "test" &&
$PHP_AUTH_PW = "123");
}
if(!$authenticated) {
header("WWW-Authenticate: Basic
realm=\"DB-Admin\"");
if (ereg("Microsoft", $SERVER_SOFTWARE))
header("Status: 401 Unauthorized");
else
header("HTTP/1.0 401 Unauthorized");
echo "Access denied";
exit;
}

</PRE>And we're another step further in writing platform/webserver
independent PHP code...

Brecht Sanders
Let dus op dit stukje:
You have to disable the built-in Authentication from IIS first to make it
wotk though (only enable "Allow Anonymous Access", disable the
other Authentication methods).
It worked for me!

The box said 'requires Windows 95 or better', so I installed Linux...

Pagina: 1