On 23-Sep-2001 Jeff Bristow wrote:
> I am trying to write a php script that will work around a http
> authentication that I do have access to. I am trying to do this so that a
> form process in my control panel can automatically have information sent to
> it from a form that a user will fill out. However, my problem is in trying
> to get PHP to automatically authenticate.
> 
> 
> for example:  I want to be able to call a url like this: 
> http://server.com/greendocks/locked/useradd.htm?user=blah&pass=blah    but
> this url is behind a http authentication.  Is it possible to have this url
> called by a php script?
> 
> And the second part of the question is can I do this process so it is
> completely invisible to the user that this page has been called? Because of
> course I don't want to allow users to have access to everything in my
> control panel.
> 

$host='server.com';
$url='/greendocks/locked/useradd.htm?user=blah&pass=blah';

$authuser='foo';      // blah ?
$authpass='baz';      // blah ?

$authenc=base64_encode("$authuser:$authpass");

$hdr =sprintf("GET %s HTTP/1.0\r\n", $url);
$hdr .="Accept: text/html\r\nAccept: text/plain\r\n";
$hdr .="User-Agent: Mozilla/1.0 (PHP spoof)\r\n";
$hdr .="Authorization: Basic $authenc\r\n\r\n";

    $fp = fsockopen($host , 80, &$errno, &$errstr, 30);
    if (!$fp) {
        die "$host open error: $errstr $errno .\n";
   }
    fputs($fp,$hdr);
    while(!feof($fp)) {
        $buff=fgets($fp,1024);
          ... do yer thang
    }
    fclose($fp);


Regards,
-- 
Don Read                                       [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to