[Jan. 2005] | // | | // | Derived from the open source HTTP_WebDAV_Server class (0.99.1) | // | by: Hartmut Holzgraefe | // | Christian Stocker | // +----------------------------------------------------------------+ // // Runs as a helper for Apache HTTP requests of this pattern... // http://[thisdomain]/p4/[Perforce path without initial //] // Requires a directory for temporary files (set below). // Requires the service of the Perforce command-line client P4. // Triggered by the following directive included in Apache's conf.ini file... // AliasMatch ^/p4.* [mydir]/p4DAV.php // Serves a single Perforce repository whose IP address is specified below // Resides in a directory [mydir] with these companion files... // 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) containing... // 4.1) _parse_lockinfo.php // 4.2) _parse_propfind.php // 4.3) _parse_proppatch.php //********************************************************** // You must edit the section below to your specifications //********************************************************** $prefix = '/p4'; // Webserver DAV trigger prefix (Apache AliasMatch) $base = $_SERVER['DOCUMENT_ROOT'].'/davroot/';// temporary file directory $depot_host = '192.168.1.3'; //$depot_host = 'public.perforce.com'; // Perforce repository $depot_port = '1666'; // Perforce contact port $depot_agent = '/usr/local/bin/p4'; // Perforce command-line client $admin_user = 'daniel_sabsay'; // Perforce admin user $admin_passwd = 'p4webdav'; // Perforce admin password $logging = 1; // Log level: 0=errors, 1=connections, 2=details, 3=debug //*************************************************************************** require_once realpath('.').'/DepotServer.php'; $URI = $_SERVER['REQUEST_URI']; $path = (strlen($URI)>strlen($prefix))? substr($URI,strlen($prefix)):'/'; $method = strtoupper($_SERVER['REQUEST_METHOD']); // PHP messages destroy XML output, so switch them off ini_set('display_errors', E_USER_NOTICE); //********************************* // BASIC CONNECTION HEADER //********************************* if ($logging>0) { error_log('DAV REQ - repository='.$depot_host.':'.$depot_port.' log level = '.$logging); error_log($method.'=>'.$path.' '.strftime('%c',time())); $request_hdrs = apache_request_headers(); unset($request_hdrs['Accept-Language']); // suppress junk $log = ''; foreach ($request_hdrs as $k=>$v) { $log .= $k.'='.$v.'--'; } error_log($log); } //********************************* // CONFIGURE SERVER INSTANCE //********************************* $P = new Depot_Filesystem; // instantiate server class $P->prefix = $prefix; $P->base = $base; $P->path = $path; $P->logging = $logging; $P->depot_host = $depot_host; $P->depot_port = $depot_port; $P->depot_agent = $depot_agent; $P->admin_user = $admin_user; // used for deleting faux directory placeholders $P->admin_passwd = $admin_passwd; //****************** // INVOKE SERVER //****************** $P->ServeRequest($method); flush(); // release any buffered output to client //********************************* // BASIC CONNECTION TRAILER //********************************* if ($logging>0) { error_log('DAV RESPONSE'); $response_hdrs = apache_response_headers(); $log = ''; foreach ($response_hdrs as $k=>$v) { $log .= $k.'='.$v.'--'; } error_log($log); } ?>