--- Matt Wondra <[EMAIL PROTECTED]> wrote: > I'm trying to include a file from an HTTP Authenticated server > in PHP. I have a valid username and password. Is there any way > to remotely login and include the file? > > Ex: > > include("https://www.url.com/incl1.php");
When allow_url_fopen is enabled, you can include a remote URL, similar to what you've shown. What PHP does for you is send an HTTP request to the remote server, receive the response, and include the content just as if you included a local file. It is this request that PHP sends that needs to have the Authorization header. To my knowledge, there is no way to add your own headers to this request made on your behalf, although you could certainly hack PHP's source to allow such a thing. What you can do is write your own code to make a request. I'll give you a quick example, but keep in mind that I'm just typing this out in an email, and it is likely to contain bugs. :-) -- $username = 'myuser'; $password = 'mypass'; $host = 'example.org'; $path = '/path/to/script.php'; $authorization = base64_encode("$username:$password); $http_response = ''; $fp = fsockopen($host, 80); fputs($fp, "GET $path HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); fputs($fp, "Authorization: $authorization\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data); while (!feof($fp)) { $http_response .= fgets($fp, 128); } fclose($fp); -- Your example cites a URL with the https scheme. To speak SSL, this example will of course require some enhancements, but hopefully this answers your question. Chris ===== Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming Fall 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php