Docunext


PHP PEAR WebDAV Server

May 19th, 2008

This package looks terrific. I tried it once years ago, and am now trying again.

pear install HTTP_WebDAV_Server
vim /usr/share/php/docs/HTTP_WebDAV_Server/db/Fileserver.sql

I installed the database, and then tried the simple script offered here:

How to install a webdav server in php

Since I run PHP as a CGI script, I had to add this snibbet I found at the php.net website:

if (!function_exists('apache_request_headers')) {
    eval('
        function apache_request_headers() {
            foreach($_SERVER as $key=>$value) {
                if (substr($key,0,5)=="HTTP_") {
                    $key=str_replace(" ","-",ucwords(strtolower(str_replace("_"," ",substr($key,5)))));
                    $out[$key]=$value;
                }
            }
            return $out;
        }
  ');
}

Reading through the docs again, the Server/Filesystem.php file is just an example of how the Server.php class can be extended. I copied this file to my working directory, started to make a few changes, and some cool ideas came to mind:

  • use MDB2 for file locking instead of only mysql
  • combine with jquery.fileTree for user-friendly navigation
  • combine with pecl svn php extension for versioning support

There are many opportunities for coolness here. I'm going to get started on something boring yet important: file uploads. To do this I'm actually going to use the HTTP_WebDAV_Client package from PEAR as well. It simply registers the webdav: and webdavs: protocols so you can do stuff like this:

$httpfile  = file_get_contents("webdav://www.example.com/foo.txt");

¥

Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022