views:

564

answers:

2

Okay, so the PHP script exists on serverA. ServerA has php safe-mode ON and WebDAV OFF. I can't change either of these factors. I want a script on serverA to get the user's login/password for another server, which we shall call serverB. ServerB has WebDAV ON.

The ultimate goal is that the user will go to the script on ServerA, put in their credentials for ServerB, and then the script will create an iCal file and place it on ServerB, allowing the user to then subscribe to the iCal file using Outlook/GoogleCalendar, etc (which requires the file to be on a WebDAV server).

So, I tried

fopen(servername/filename, r)

and was able to read files on the remote server. But when I tried

fopen(servername/filename, w)

I get an error that the HTTP wrapper doesn't support writing, only reading.

Long story short, is there a way to connect to this server and authenticate, write a file, then close the connection WITHOUT using any of the already-existing WebDAV libraries for PHP and without getting hit with a safe-mode permissions error?

Thanks!

A: 

The issue here is that Safe-mode is designed to restrict you so you can not execute things outside your "safe" zone.

What you could try (if you can) is to modify the safe_mode_exec_dir in php.ini, then you can start external programs that could do the writing of the file for you (if they reside in this safe-mode directory

About authenticating, I'm not sure, perhaps someone can answer that in more detail.

Ólafur Waage
A: 

The problem is that the the HTTP protocol wrapper for PHP doesn't do PUT. You should attempt to write your own, with either fsockopen, or preferably something like curl.

http://ca3.php.net/manual/en/wrappers.http.php

This has nothing to do with safe mode.

Evert