phpbar.de logo

Mailinglisten-Archive

[php] HTTP Basic Authentication Test Script !

[php] HTTP Basic Authentication Test Script !

Ivan Schmid php_(at)_phpcenter.de
Wed, 4 Sep 2002 03:45:41 +0200


Hallo PHP Interessierte,

Hier ein kleines Script um die http basic authentication auf einem anderen
Server mittels PHP zu testen !
Für irgenwelche Verbesserungsvorschläge würde ich mich sehr freuen.

------------- start ----------------
<html>
<head><title>Astalavista Group</title></head>
<body>
<form method="post" action="<? PHP_SELF;?>">
 <input type="text" name="host" value="www.target.com">
 <input type="text" name="path" value="/protected-folder/">
 <input type="text" name="username" value="username">
 <input type="text" name="password" value="password">
 <input type="submit" name="submit" value="try">
</form>if you get a HTTP/1.1 200 OK then the username, password is
matching!<br>
<?
if (isset($submit)) {

$authstring = base64_encode("$username:$password");
$fp = fsockopen ($host, 80);
if ($fp) {

fputs ($fp, "
POST $path HTTP/1.1
Host: $host
Content-length: 7
Accept-Language: en
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Accept-Encoding: gzip, deflate
Authorization: Basic $authstring
Connection: close

a=1&b=2

");
while (!feof($fp)) $reply .= fgets ($fp);
echo $reply;
flush();
fclose ($fp);
}
}
?>
</body>
</html>
------------- ende ----------------

Ivan - www.astalavistagroup.ch


php::bar PHP Wiki   -   Listenarchive