From 5cfc38b4f633e87d7c224f27eb61d70ca0e80723 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 10 May 2008 21:15:46 +0000 Subject: [PATCH] moved webdav handler in the root dir, as its now a general service and not only used by filemanager --- filemanager/webdav.php | 51 ++++---------------------- phpgwapi/inc/class.egw_vfs.inc.php | 2 +- webdav.php | 57 ++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 46 deletions(-) create mode 100644 webdav.php diff --git a/filemanager/webdav.php b/filemanager/webdav.php index 0abf8c5590..e0f9874c71 100644 --- a/filemanager/webdav.php +++ b/filemanager/webdav.php @@ -1,54 +1,15 @@ - * @copyright (c) 2006-8 by Ralf Becker + * @copyright (c) 2008 by Ralf Becker * @version $Id$ */ -/** - * check if the given user has access - * - * Create a session or if the user has no account return authenticate header and 401 Unauthorized - * - * @param array &$account - * @return int session-id - */ -function check_access(&$account) -{ - $account = array( - 'login' => $_SERVER['PHP_AUTH_USER'], - 'passwd' => $_SERVER['PHP_AUTH_PW'], - 'passwd_type' => 'text', - ); - if (!($sessionid = $GLOBALS['egw']->session->create($account))) - { - header('WWW-Authenticate: Basic realm="eGroupWare WebDAV"'); - header("HTTP/1.1 401 Unauthorized"); - header("X-WebDAV-Status: 401 Unauthorized", true); - exit; - } - return $sessionid; -} - -// if we are called with a /apps/$app path, use that $app as currentapp, to not require filemanager rights for the links -$parts = explode('/',$_SERVER['PATH_INFO']); -$app = count($parts) > 3 && $parts[1] == 'apps' ? $parts[2] : 'filemanager'; - -$GLOBALS['egw_info']['flags'] = array( - 'disable_Template_class' => True, - 'noheader' => True, - 'currentapp' => $app, - 'autocreate_session_callback' => 'check_access', -); -// if you move this file somewhere else, you need to adapt the path to the header! -include('../header.inc.php'); - -$webdav_server = new vfs_webdav_server(); -$webdav_server->ServeRequest(); \ No newline at end of file +include('../webdav.php'); \ No newline at end of file diff --git a/phpgwapi/inc/class.egw_vfs.inc.php b/phpgwapi/inc/class.egw_vfs.inc.php index cca542a6e5..cd22dbbc57 100644 --- a/phpgwapi/inc/class.egw_vfs.inc.php +++ b/phpgwapi/inc/class.egw_vfs.inc.php @@ -954,7 +954,7 @@ class egw_vfs extends vfs_stream_wrapper { $path = parse_url($path,PHP_URL_PATH); } - return '/filemanager/webdav.php'.$path; + return '/webdav.php'.$path; } /** diff --git a/webdav.php b/webdav.php new file mode 100644 index 0000000000..06e1623537 --- /dev/null +++ b/webdav.php @@ -0,0 +1,57 @@ + + * @copyright (c) 2006-8 by Ralf Becker + * @version $Id$ + */ + +/** + * check if the given user has access + * + * Create a session or if the user has no account return authenticate header and 401 Unauthorized + * + * @param array &$account + * @return int session-id + */ +function check_access(&$account) +{ + $account = array( + 'login' => $_SERVER['PHP_AUTH_USER'], + 'passwd' => $_SERVER['PHP_AUTH_PW'], + 'passwd_type' => 'text', + ); + if (!($sessionid = $GLOBALS['egw']->session->create($account))) + { + header('WWW-Authenticate: Basic realm="'.vfs_webdav_server::REALM.'"'); + header("HTTP/1.1 401 Unauthorized"); + header("X-WebDAV-Status: 401 Unauthorized", true); + exit; + } + return $sessionid; +} + +// if we are called with a /apps/$app path, use that $app as currentapp, to not require filemanager rights for the links +$parts = explode('/',$_SERVER['PATH_INFO']); +$app = count($parts) > 3 && $parts[1] == 'apps' ? $parts[2] : 'filemanager'; + +$GLOBALS['egw_info'] = array( + 'flags' => array( + 'disable_Template_class' => True, + 'noheader' => True, + 'currentapp' => $app, + 'autocreate_session_callback' => 'check_access', + ) +); +// if you move this file somewhere else, you need to adapt the path to the header! +include(dirname(__FILE__).'/header.inc.php'); + +$webdav_server = new vfs_webdav_server(); +$webdav_server->ServeRequest(); \ No newline at end of file