It's very simple.

  • Download this package, and decompress it.
  • The inc folder contains PEAR and the HTTP_WebDAV_Server class.
  • Copy the inc folder and authenticate.php file in the include_path (see php.ini)
  • Copy webdav.php file in the root of your site.
  • Create Table with Fileserver.sql for the lock and unlock operations of the WebDAV server module.

The authenticate.php file contains a digest authentification or You can replace this function with a simple .htacess.

The webdav.php file create a webdav server

To read authenticate.php


<?
include_once("authenticate.php");
 
ini_set("error_reporting", "");
# umask(2);
 
# Activate if your PHP is CGI mode
$phpcgi = 0;
# With authentication
$AUTHWEBDAV = 1;
# Name of your restricted area
$realm = 'Restricted area Keyphrene';
$DBHOST= "your host database";
$DB_WEBDAV = "your dbname to lock webdav";
$DBUSER = "your login";
$DBPWD = "your password";
$users = array($DBUSER => $DBPWD);
 
# Remove $AUTHWEBDAV section if you use .htacess file for authentication.
if ($AUTHWEBDAV == 1) {
  # With this authentication method, 
  # your password is not readable when you use this service
  AuthenticationDigestHTTP($realm, $users, $phpcgi); # With method your password is hashed
  # AuthenticationBasicHTTP($realm, $users, $phpcgi); # With method your password is clear
}
 
require_once "HTTP/WebDAV/Server/Filesystem.php";
$server = new HTTP_WebDAV_Server_Filesystem();
# Database configuration for the lock method
$server->db_host = $DBHOST;
$server->db_name = $DB_WEBDAV;
$server->db_user = $DBUSER;
$server->db_passwd = $DBPWD;
# Real path of your site
$server->ServeRequest($DOCUMENT_ROOT."/www/");
 
?>

To use this service, you must connect you at this adress http://mysite.org/webdav.php. You can configure a lot of access on your site. Becareful, if you must copy files on your server, you must use the good permissions with the FTP client.

Test your webdav connection with Naja, so create a signet

Now, you can browse on your server with a webdav client

Bookmarks