Solved

(UNC path with Apache and PHP)

Posted on 2002-05-28
15
1,334 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
Comment Utility
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
Comment Utility
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
Comment Utility



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
 
LVL 5

Expert Comment

by:dkjariwala
Comment Utility
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
Comment Utility
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:RQuadling
Comment Utility
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
Comment Utility
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
Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
Comment Utility
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:RQuadling
Comment Utility
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
Comment Utility
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:
RQuadling earned 150 total points
Comment Utility
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
Comment Utility
Ill try and I come back with you on this..

Styve
0
 

Author Comment

by:Styve
Comment Utility
(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
Comment Utility
thks for all your help..

Styve
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now