schotte
05-08-2005, 01:44 PM
Hi there,
I was wondering, whether it is possible to "login" to a .htaccess protected folder on my server using php's function fsockopen. At the moment I can run the script which is stored in the folder which I want to protect. The script looks like this:
<?php
function connect($sHost) {
$rSocket = fsockopen($sHost, 80, $iError, $sError);
if (!$rSocket) die($iError . ": " . $sError);
else {
$sUrl = "/path/to/script.php";
fputs($rSocket, "GET " . $sUrl . " HTTP/1.1\r\nHost: " . $sHost . "\r\n\r\n");
fclose($rSocket);
}
}
?>
So I think all I need to change is the fputs second argument to send username and password. But what would I need to write?
Cheers,
Frank
I was wondering, whether it is possible to "login" to a .htaccess protected folder on my server using php's function fsockopen. At the moment I can run the script which is stored in the folder which I want to protect. The script looks like this:
<?php
function connect($sHost) {
$rSocket = fsockopen($sHost, 80, $iError, $sError);
if (!$rSocket) die($iError . ": " . $sError);
else {
$sUrl = "/path/to/script.php";
fputs($rSocket, "GET " . $sUrl . " HTTP/1.1\r\nHost: " . $sHost . "\r\n\r\n");
fclose($rSocket);
}
}
?>
So I think all I need to change is the fputs second argument to send username and password. But what would I need to write?
Cheers,
Frank