note 58758 added to function.file-get-contents
| From: | richard dot quadling at bandvulc dot co dot uk | Date: | Tue, 15 Nov 2005 10:47:18 +0000 |
| Subject: | note 58758 added to function.file-get-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98580@lists.php.net to get a copy of this message | ||
If, like me, you are on a Microsoft network with ISA server and require NTLM authentication, certain
applications will not get out of the network. SETI@Home Classic and PHP are just 2 of them.
The workaround is fairly simple.
First you need to use an NTLM Authentication Proxy Server. There is one written in Python and is
available from http://apserver.sourceforge.net/. You
will need Python from http://www.python.org/.
Both sites include excellent documentation.
Python works a bit like PHP. Human readable code is handled without having to produce a compiled
version. You DO have the opportunity of compiling the code (from a .py file to a .pyc file).
Once compiled, I installed this as a service (instsrv and srvany - parts of the Windows Resource
Kit), so when the server is turned on (not logged in), the Python based NTLM Authentication Proxy
Server is running.
Then, and here is the bit I'm really interested in, you need to tell PHP you intend to route
http/ftp requests through the NTLM APS.
To do this, you use contexts.
Here is an example.
<?php
// Define a context for HTTP.
$aContext = array(
'http' => array(
'proxy' => 'tcp://127.0.0.1:8080', // This needs to be the server and the
port of the NTLM Authentication Proxy Server.
'request_fulluri' => True,
),
);
$cxContext = stream_context_create($aContext);
// Now all file stream functions can use this context.
$sFile = file_get_contents("http://www.php.net",
False, $cxContext);
echo $sFile;
?>
Hopefully this helps SOMEONE!!!
----
Manual Page -- http://www.php.net/manual/en/function.file-get-contents.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58758
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58758&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58758&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58758&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58758&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58758&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58758&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58758&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58758&report=yes
Search -- http://master.php.net/manage/user-notes.php