<?php //==========================================------ // p4DAV.php Implements a Perforce WebDAV server //==========================================------ // Derived from the open source HTTP_WebDAV_Server class (0.99.1) // // Runs as a helper for Apache HTTP requests // Depends on the following directive included in Apache's conf.ini file... // AliasMatch ^/p4.* [documentroot]/p4dav/p4DAV.php // Invoked by a URLs http://thisdomain/p4/... // Resides in directory "p4dav" in Apache document root // Contents of the p4dav directory... // 1) p4DAV.php [this file] (heavily modified from davserver.php) // 2) DepotServer.php (heavily modified from FileSystem.php) // 3) DAVServer.php (derived with slight mods from Server.php) // 4) Tools (a directory, unmodified from open source distribution) // 4.1) _parse_lockinfo.php // 4.2) _parse_propfind.php // 4.3) _parse_proppatch.php // // Expects a directory "davroot" in the Apache document root for temporary files // //========================================== // // TO DO: // adjust client line-end parameter to correspond with client OS type?? // require_once realpath('.').'/DepotServer.php'; $prefix = '/p4'; // Webserver DAV trigger prefix (Apache AliasMatch) $URI = $_SERVER['REQUEST_URI']; $base = $_SERVER['DOCUMENT_ROOT'].'/davroot/'; $path = (strlen($URI)>strlen($prefix))? substr($URI,strlen($prefix)):'/'; $method = strtoupper($_SERVER['REQUEST_METHOD']); $bug = false; if ($bug) { $fp = fopen('php://input','r'); $input = fread($fp,2000); // Capture non-header data fclose($fp); $LOG = realpath('~Sites/davroot/webdav_log.txt'); $fp = fopen($LOG,'a'); if ($fp) { fwrite($fp,$input,strlen($input));fclose($fp); } ob_start(); } $depot = new Depot_Filesystem; $depot->prefix = $prefix; $depot->base = $base; $depot->path = $path; //$depot->depot_host = 'localhost'; //$depot->depot_host = 'public.perforce.com'; $depot->depot_host = '192.168.1.36'; $depot->depot_port = '1666'; $depot->depot_agent = '/usr/local/bin/p4'; $depot->ServeRequest($method); if ($bug) { $s = ob_get_flush(); } // *************** // START BASIC LOG // *************** flush(); $msg = "\n\n"; $req_hdrs = apache_request_headers(); unset($req_hdrs['Accept-Language']); // suppress junk // $msg. =join('',headers_list()); // PHP5 only $lt = localtime(time(),true); $t = $lt['tm_hour'].':'.$lt['tm_min'].':'.$lt['tm_sec']; $msg .= ''.date('m/d/Y',time()).'['.$t."] ".$_SERVER['REMOTE_ADDR'].'=>'; $msg .= $method.' '.$path."\n"; $p=array(); foreach ($req_hdrs as $k=>$v) { $p[]=$k.'='.$v; } $msg .=join('',$p)."\n"; $LOG = realpath('/Users/daniel/Sites/davroot/webdav_log.txt'); $fp = fopen($LOG,'a'); $msg .= $s; if ($fp) { fwrite($fp,$msg,strlen($msg));fclose($fp); } // *************** // END BASIC LOG // *************** ?>
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#13 | 4802 | Daniel Sabsay | Change default repository address to "localhost" | ||
#12 | 4801 | Daniel Sabsay | Copyright and default user name cleaned up | ||
#11 | 4800 | Daniel Sabsay |
Final documentation update GET method updated Log now reports depot host & port being served |
||
#10 | 4799 | Daniel Sabsay | Remove otiose debug logging code | ||
#9 | 4796 | Daniel Sabsay | Cosmetic change to log mechanism | ||
#8 | 4779 | Daniel Sabsay | A few bugs chased | ||
#7 | 4778 | Daniel Sabsay |
Improvements in logging (now shows response headers) Change in directory searching mechanism Now appropriately handles If-Modified-Since headers |
||
#6 | 4774 | Daniel Sabsay | Repackaged functions all working | ||
#5 | 4750 | Daniel Sabsay |
Mac Finder can now mount the root (repository) level. Directory last-modified dates are now retrieved. Full log implementation now shows both sides of dialog. |
||
#4 | 4749 | Daniel Sabsay |
The code now uses no persistant workspaces or changelists. Switched the faux directory mechanism to use deleted placeholder files. Switched the logging mechanism to use the webserver logging methods. |
||
#3 | 4725 | Daniel Sabsay | Changes to the DELETE and LIST logic | ||
#2 | 4717 | Daniel Sabsay | Updated and clarified the Read Me section | ||
#1 | 4711 | Daniel Sabsay | PUT works for first time |