(UNC path with Apache and PHP)

Hi, i'm using apache 1.3.13 PHP4.1.1 on win2000. I do not want to map a drive on my web server but I have to access to some files on another server.

The reason is that I have to copy some files to my webserver and when the drive is map i cannot use function like fopen() or other.

Is there a way around this with php4 ? I have eard somewhere that unc path are no longer support with php4, is that right ? And if not, How can I connect to this server without mapping it?

thank in advance..

Styve
StyveAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Richard QuadlingConnect With a Mentor Senior Software DeveloperCommented:
If you try turning on Safe Mode and adding in the path into safe_mode_include_dir. Does that work?

0
 
dkjariwalaCommented:
One thing you can do is to run FTP service on the target machine.

PHP provides very good support to FTP and you can easily get files from other server.

JD
0
 
StyveAuthor Commented:
The other server can not be set as an FTP server..:( The Admin wont let me do this on that server.

Styve
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
lokeshvCommented:



I am not sure about this but I think it´s a security issue. Accessing another computer needs authentication. Maybe if the other computer running a webserver and you can get the result via the HTTP protocol.
Or maybe you should use DCOM, CORBA or SOAP ;-)


Lk
0
 
dkjariwalaCommented:
I guess he wants to transfer *files* in that case DCOM,CORBA won't help I guess.

JD
0
 
vmvCommented:
Try running Apache as the user who created the drive mapping. Of course it's a bad thing to do, but it may solve the problem...
0
 
Richard QuadlingSenior Software DeveloperCommented:
I use PHP on my local pc and I am on an internal LAN served by W2K servers. I cannot access mapped drives via PHP. But they are accessible to me if I go to explorer/command prompt, so why not PHP?

I've tried a lot of different methods to try and get a firewall log file off the server onto my pc for analysis via a PHP program, but no joy.

Looking for an answer!
0
 
StyveAuthor Commented:
The thing is yes, it is file transfert that i want to do and no the other server cannot be set to be file server (either http, ftp, telnet, so on..)...

Like RQuadling said, I can access this server via mapping and explorer on my web server but not via php.

As running Apache as the user who created the drive mapping, i'm not so sure how to do this. I'm admin of the pc witch apache is install to and I have mapped the drive under this status (admin) as well a the install of apache. If I look in properties/security for this drive, the group Everyone have full access and right. Can I give those right to an application (php) like giving rights to a domain group, or individual profil ?...

I have some other tests to do  in regards of this manner and I'll let you know if I solve this access problem...

Thank for all your comments..

Styve
0
 
Richard QuadlingSenior Software DeveloperCommented:
Something I've not tried yet, but I've just grabbed from the PHP documentation ...


If you are experiencing problems with reading and writing to files and you're using the server module version of PHP, remember to make sure that the files and directories you're using are accessible to the server process.

On the Windows platform, be careful to escape any backslashes used in the path to the file, or use forward slashes.


The first part relates to using PHP ISAPI (which I do) and the server process does NOT access files on a remote server. It is the Workstation service that does that. (I think).

The second part is one of those obvious things, but try it anyway.

Regards,

Richard Quadling.
0
 
StyveAuthor Commented:
I've tried with both ways (slash things) like :

fopen($myDrive.":\\".$myRep."\\".$myFile, "r");

or

fopen($myDrive.":/".$myRep."/".$myFile, "r");

they both work for me in a windows environment but localy only...

Styve
0
 
Richard QuadlingSenior Software DeveloperCommented:
I've had a look at the source. There seems to be a lot of references to safe_mode_include_dir

I think that if PHP was in safe mode, add the safe_mode_include_dir contained the directory of the file on the server, then it MAY open the file!!!!

The Safe Mode docs isn't too clear (doesn't even mention fopen), but it might be worth a try!

The docs say that Safe Mode is ...


The PHP safe mode is an attempt to solve the shared-server security problem. It is architecturally incorrect to try to solve this problem at the PHP level, but since the alternatives at the web server and OS levels aren't very realistic, many people, especially ISP's, use safe mode for now.


So, try and see is the answer I think. I think you can probably do this for your OWN servers, but an ISP may have deep reservations about allowing you to change these settings!

Regards,

Richard Quadling.
0
 
StyveAuthor Commented:
take on my php.ini...

;
; Safe Mode
;
safe_mode = Off

; By default, Safe Mode does a UID compare check when
; opening files. If you want to relax this to a GID compare,
; then turn on safe_mode_gid.
safe_mode_gid = Off

; When safe_mode is on, UID/GID checks are bypassed when
; including files from this directory and its subdirectories.
; (directory must also be in include_path or full path must
; be used when including)
safe_mode_include_dir =                                        

; When safe_mode is on, only executables located in the safe_mode_exec_dir
; will be allowed to be executed via the exec family of functions.
safe_mode_exec_dir =

; open_basedir, if set, limits all file operations to the defined directory
; and below.  This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file.
;
;open_basedir =

So this not seem like my problem..

thank for those details

Styve
0
 
StyveAuthor Commented:
Ill try and I come back with you on this..

Styve
0
 
StyveAuthor Commented:
(Accessing files from a mapped drive, WIN2000 Professional and APACHE/PHP4)

Ok, I finaly make it work...

Thanks for all support regarding this problem.

Here's how,

- Start/Settings/Control panel/Administratives tools/Services

- check for Apache service

- Right-click/Properties

- Tab "Log On", you'll have to choice :

     - Local system account (this should be the one you should have checked by default)
     - This account

- Choose "This account" and than "Browse".

- Select ".\Administrator" and enter the appropriate password

- Apply

- Reboot

Now, your Apache service will have Administrator right on logon instead of those of the
profil of the local system.

Ok then, for more security, I have done some change on my php.ini, just to be sure..;o)
(Note, accessing files works before and after the change that I have make in my php.ini)

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;


; Windows: "\path1;\path2"
include_path = ".;i:\"          //Witch I: is my mapped drive


;;;;;;;;;;;;;;;;;;;;;;;;
; Safe Mode
;;;;;;;;;;;;;;;;;;;;;;;;

safe_mode = On
safe_mode_gid = On
safe_mode_include_dir =     "i:\"     //Witch I: is my mapped drive

I suggest you to read about security issue at :

http://www.php.net/manual/en/configuration.php


Hope this will help Win2000 and Apache user's on LAN project development...

Styve
0
 
StyveAuthor Commented:
thks for all your help..

Styve
0
All Courses

From novice to tech pro — start learning today.