简体   繁体   中英

PHP open_basedir with UNC path

Running PHP 5.3.1 on a Windows server, I have to modify a PHP script to access XML files on a network share. For various reasons the files cannot be placed on the PHP server, and I am not allowed to create a mapped drive on the PHP server so I have to modify the open_basedir parameter in PHP.ini to include the UNC path to the share, eg:

open_basedir = "E:\inetpub\;E:\DB_HubDataFiles\;\\stdmfps01\inter-departements$\CVSC-CDT-Estimation-Cedule\"

However when I try to access files on the share I get the "open_basedir restriction in effect" error. I am trying to access the files as follows:

$jobfilename = "//stdmfps01/inter-departements$/CVSC-CDT-Estimation-Cedule/" .$job . ".xml";
if (file_exists($jobfilename)) {
    $jobxml = simplexml_load_file($jobfilename);
    etc...

I have been assured that it is not a problem of rights, and anyway the error indicates a problem with open_basedir. So my questions are:

  1. does open_basedir handle UNC paths under Windows (I have seen conflicting statements about this)?
  2. if so is there some problem with my syntax?
  3. do I have other options than using open_basedir?

Thanks.

Anyway, here's what ended up working for me, even if I am not totally clear why:

In php.ini changed the open_basedir parameter to use the IP address instead of the server name, and used the parent directory of the directory where my files are located, instead of the directory itself:

\\\nnn.nnn.nnn.nnn\inter-departements$\

instead of:

 \\servername\inter-departements$\CVSC-CDT-Estimation-Cedule\

In the PHP script used the IP address as well:

$jobfile = "//nnn.nnn.nnn.nnn/inter-departements$/CVSC-CDT-Estimation-Cedule/" . ($jobid) . ".xml";

这对我有用:用斜杠替换反斜杠

open_basedir = "E:\inetpub\;E:\DB_HubDataFiles\;//stdmfps01/inter-departements$/CVSC-CDT-Estimation-Cedule/"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM