Page 1 of 1

Including files in virtual directories on IIS

Posted: Wed Jun 12, 2002 10:23 am
by thomkenney
Hello all,

I have an issue working with NT4 Server, IIS4 and PHP4. I have created a couple of virtual directories in the website I am running PHP in through IIS. These are looked upon as subdirectories of the web.

I have been able to successfully use PHP to provide links to images in these virtual directories pretty easily, so I know that IIS recognizes them and HTML can find them.

Here's what I would like to do...I would like to have several directories where include files are kept. For instance, one virtual IIS directory is called "newslinks", and points to a directory on another server.

I'd like to be able to call this...

<?
include "newslinks/skedselect.htm"
?>

...where "skedselect.htm" is a file in the "newslinks" virtual IIS directory. Problem is, PHP doesn't recognize newslinks. I can include files pretty easily if I move them to the root of IIS or create a folder in IIS and look there for the file to include.

I've tried several things, but need a simple way to be able to get HTML files to include from various servers, and don't want to modifiy the PHP.INI file all the time to get the right directories, I think management through IIS would be better using virtual directories.

Anyone have any thoughts on this? Any help or direction would be most appreciated!

Posted: Wed Jun 12, 2002 10:41 am
by volka
from the user contributed notes for realpath
I have PHP4 running on Win2k IIS and consequently the $DOCUMENT_ROOT is not
automatically defined by PHP. Since I often need to find the absolute path
of a virtual path, I created a workaround function that acts like
server.mappath() from ASP:
// relative path to virtual directory root
$relative = str_repeat('../',substr_count($PATH_INFO,'/')-1);

function mappath($path) {
// transforms virtual or relative path to an absolute path
global $relative;
return realpath(substr($path,0,1)=='/' ? $relative.substr($path,1) :
$path);
}
Hope this is helpful to some of you.
> Dave [twadzilla.com]

Posted: Wed Jun 12, 2002 11:33 am
by thomkenney
Here's a tip I received from Mike Johnson at bigattichouse.com...instead of using the include, I used this with great success!

$fp = fopen("http://192.168.6.7/newslink/sked/skedselect.htm", "rb");
fpassthru($fp);
flush();

Works like a charm for me, and it uses the virtual directories I needed.

Thanks, Mike!

Posted: Wed Jun 12, 2002 1:31 pm
by volka
ok, I thought you wanted to include a script-part. I should read the posts more attentively (skedselect.htm) ;)