Solved

(UNC path with Apache and PHP)

Posted on 2002-05-28
15
1,345 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:Styve
  • 7
  • 4
  • 2
  • +2
15 Comments
 
LVL 5

Expert Comment

by:dkjariwala
ID: 7040042
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
 

Author Comment

by:Styve
ID: 7040071
The other server can not be set as an FTP server..:( The Admin wont let me do this on that server.

Styve
0
 
LVL 4

Expert Comment

by:lokeshv
ID: 7040812



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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
LVL 5

Expert Comment

by:dkjariwala
ID: 7040987
I guess he wants to transfer *files* in that case DCOM,CORBA won't help I guess.

JD
0
 
LVL 2

Expert Comment

by:vmv
ID: 7041101
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
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7041251
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
 

Author Comment

by:Styve
ID: 7041735
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
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7041840
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
 

Author Comment

by:Styve
ID: 7041860
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
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7042144
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
 

Author Comment

by:Styve
ID: 7042377
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
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 150 total points
ID: 7043978
If you try turning on Safe Mode and adding in the path into safe_mode_include_dir. Does that work?

0
 

Author Comment

by:Styve
ID: 7044322
Ill try and I come back with you on this..

Styve
0
 

Author Comment

by:Styve
ID: 7044578
(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
 

Author Comment

by:Styve
ID: 7044586
thks for all your help..

Styve
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question